C
CHWRoma
I have two list boxes in my form. they are both set up to choose more then
one item in each list box but you also have to choose at least one item from
each list box. I need to be able to also pick one item from one box and not
the other, and vice/versa. Example:
List Box 1 - dog, cat, child
List Box 2 - litter, food, toys
I want to be able to chose dog but not anything from List Box 2 - litter /
food / toys
Here's the code I am using.
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
For Each varItem In Me!List_Provider_Name.ItemsSelected
strCriteria = strCriteria & ",'" &
Me!List_Provider_Name.ItemData(varItem) & "'"
Next varItem
If Len(strCriteria) = 0 Then
MsgBox "You did not select anything from the list" _
, vbExclamation, "Nothing to find!"
Exit Sub
End If
strCriteria = Right(strCriteria, Len(strCriteria) - 1)
strSQL = "SELECT * FROM dbo_PROVIDER_VENDOR " & _
"WHERE dbo_PROVIDER_VENDOR.VENDOR_NAME IN(" & strCriteria & ");"
qdf.SQL = strSQL
DoCmd.OpenQuery "qryMultiSelect"
DoCmd.RunMacro "Open and Close Provider Name Table"
Thanks for any help.......Roma
one item in each list box but you also have to choose at least one item from
each list box. I need to be able to also pick one item from one box and not
the other, and vice/versa. Example:
List Box 1 - dog, cat, child
List Box 2 - litter, food, toys
I want to be able to chose dog but not anything from List Box 2 - litter /
food / toys
Here's the code I am using.
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
For Each varItem In Me!List_Provider_Name.ItemsSelected
strCriteria = strCriteria & ",'" &
Me!List_Provider_Name.ItemData(varItem) & "'"
Next varItem
If Len(strCriteria) = 0 Then
MsgBox "You did not select anything from the list" _
, vbExclamation, "Nothing to find!"
Exit Sub
End If
strCriteria = Right(strCriteria, Len(strCriteria) - 1)
strSQL = "SELECT * FROM dbo_PROVIDER_VENDOR " & _
"WHERE dbo_PROVIDER_VENDOR.VENDOR_NAME IN(" & strCriteria & ");"
qdf.SQL = strSQL
DoCmd.OpenQuery "qryMultiSelect"
DoCmd.RunMacro "Open and Close Provider Name Table"
Thanks for any help.......Roma