S
Soboths
I have been able to build a query that is filtered by a selection in a
Listbox in a form, but now i want to use a multi select list box so that two
or more items can be included in the query. I constructed the query pointing
to the List box which is not working. All I get is an empty dataset.
Form Name: Receipts_Selection_Form
List Box Name: List42
List Source: TBL_SLocation
Multi Select: Simple
With below code
----------
Private Sub List42_AfterUpdate()
Dim frm As Form
Dim ctl As Control
Dim varItem As Variant
Dim strSQL As String
Dim strWhere As String
Set frm = Forms!Receipts_Selection_Form
Set ctl = Me![List42]
strSQL = "Select * from TBL_SLocation"
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ", "
Next varItem
End Sub
Listbox in a form, but now i want to use a multi select list box so that two
or more items can be included in the query. I constructed the query pointing
to the List box which is not working. All I get is an empty dataset.
Form Name: Receipts_Selection_Form
List Box Name: List42
List Source: TBL_SLocation
Multi Select: Simple
With below code
----------
Private Sub List42_AfterUpdate()
Dim frm As Form
Dim ctl As Control
Dim varItem As Variant
Dim strSQL As String
Dim strWhere As String
Set frm = Forms!Receipts_Selection_Form
Set ctl = Me![List42]
strSQL = "Select * from TBL_SLocation"
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ", "
Next varItem
End Sub