Hello
I have a search form with a multi-select listbox and a button that opens a continuous form with the search results.
Here's the problem: when I select more than one item, the form shows all risults with one item OR another item, I need to search for all records that contain all the selected items. I need your help as I'm a noob with VBA
This is the code I am using:
Code:
Private Sub Search_Click()
Dim strSelection As String, varItem As Variant
Dim strSQL As String
For Each varItem In Me!ListbI.ItemsSelected
strSelection = strSelection & Me!ListbI.ItemData(varItem) & ","
Next varItem
If Len(strSelection) = 0 Then
MsgBox "Select at least one item!", vbExclamation, "Attention!"
Exit Sub
End If
strSelection = Left(strSelection, Len(strSelection) - 1)
strSQL = "IDIng IN (" & strSelection & ") "
DoCmd.OpenForm "Filter", acNormal, , strSQL
DoCmd.Close acForm, "Search"
Exit_Search_Click:
Exit Sub
End Sub
thank you