As pointed out, you'll need to use an "In" clause.
such as (in red)
Code:
Dim sCategorySub As String
sCategorySub = "SELECT [tblCategorySub].[SubCategoryID]," & _
" [tblCategorySub].[CategoryID]," & _
" [tblCategorySub].[SubCategoryName] " & _
"FROM tblCategorySub " & _
"WHERE [CategoryID] In(" & getLBX(Me.Lst1) & ")"
Me.Lst2.RowSource = sCategorySub
I use a public function with Multi-select listboxes which returns a delimited string of your selections.
Code:
Public Function getLBX(lbx As ListBox, Optional intColumn As Variant = 0, Optional Seperator As String = ",", _
Optional delim As Variant = Null) As String
'Iterates thru the multiselect listbox and constructs an array of the selected items
'Arguments:
'Lbx is Listbox Object ie.Me.MyListbox
'intColumn is the column # to be returned
'Seperator is the character seperating items in array returned
'Delim is optional delimiter to be return in array ie. #1/1/2001#,#12/25/2015#
Dim strlist As String
Dim varSelected As Variant
'On Error GoTo getLBX_Error
If lbx.ItemsSelected.Count = 0 Then
'MsgBox "Nothing selected"
Else
For Each varSelected In lbx.ItemsSelected
If Nz(lbx.Column(intColumn, (varSelected)), "") <> "" Then
strlist = strlist & delim & lbx.Column(intColumn, (varSelected)) & delim & Seperator
Else
strlist = strlist
End If
Next varSelected
If Nz(strlist, "") <> "" Then
strlist = Left$(strlist, Len(strlist) - 1) 'remove trailing comma
End If
End If
getLBX = strlist
On Error GoTo 0
Exit Function
getLBX_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure getLBX of Module modLBX"
End Function