If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Unanswered: Combo Box problem

Hi everyone!

I do not know what I am doing wrong with the VB Code. When I select a value in my Combo Box, I must see related information in the sub form below the Combo Box. Can anyone look at it and solve it for me.

You can find attached MS Access 2007 file which is compressed with 7zip. Just change the extension of the file to .7z in order to be able to open the file.

further more as you run the setfilter code on the forms initial load you need to cater for the possibility that the combo box doesnt' have a value. either explicitly set a value on start up OR modify your code to spot there is no value and take appropriate action (or inaction)

Code:

Sub SetFilter()
Dim LSQL As String
LSQL = "select * from [Order Details]"
If Not IsNull(Combo2) Then ' the user has selected an order number
LSQL = LSQL & " where [Order ID] = " & Combo2
'else nothing selected so dont apply the filter
End If
Form_OrderDetails_sub.RecordSource = LSQL
Form_OrderDetails_sub.Requery
End Sub