mtownbound
Technical User
So I have one multi-select list box that works fine, but I need to add a second field. I added the second string but my "And" statement wasn't working.
Here's my original, so where do I need to add the code for the second field(the message box is just for testing):
Private Sub cmdRunReport_Click()
Dim varItem As Variant
Dim strSearch As String
Dim Task As String
For Each varItem In Me.lboShoes.ItemsSelected
strSearch = strSearch & "," & Me.Shoes.ItemData(varItem)
Next varItem
MsgBox (strSearch)
If Len(strSearch) = 0 Then
Task = "select * from qryShoesinInventory"
Else
strSearch = Right(strSearch, Len(strSearch) - 1)
Task = "select * from qryShoesinInventory where ([Model] in (" & strSearch & "))"
End If
DoCmd.ApplyFilter Task
DoCmd.OpenReport "rptShoesinInventory", acViewPreview, , "Model IN(" & strSearch & ")"
End Sub
Here's my original, so where do I need to add the code for the second field(the message box is just for testing):
Private Sub cmdRunReport_Click()
Dim varItem As Variant
Dim strSearch As String
Dim Task As String
For Each varItem In Me.lboShoes.ItemsSelected
strSearch = strSearch & "," & Me.Shoes.ItemData(varItem)
Next varItem
MsgBox (strSearch)
If Len(strSearch) = 0 Then
Task = "select * from qryShoesinInventory"
Else
strSearch = Right(strSearch, Len(strSearch) - 1)
Task = "select * from qryShoesinInventory where ([Model] in (" & strSearch & "))"
End If
DoCmd.ApplyFilter Task
DoCmd.OpenReport "rptShoesinInventory", acViewPreview, , "Model IN(" & strSearch & ")"
End Sub