S
Soboths
Hello all,
Hoping someone can help me with list box multi selection problem.
I have been able to build a query that is filtered by a selection in a
List box, but now that I want to use a multi select list box so that two or
more items can be included in the query.
List box Name is: List42
List box source:TBL_Slocation
Form name: Receipts_Selection_Form
Below is my code which is not working
------
Private Sub List42_BeforeUpdate(Cancel As Integer)
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
Hoping someone can help me with list box multi selection problem.
I have been able to build a query that is filtered by a selection in a
List box, but now that I want to use a multi select list box so that two or
more items can be included in the query.
List box Name is: List42
List box source:TBL_Slocation
Form name: Receipts_Selection_Form
Below is my code which is not working
------
Private Sub List42_BeforeUpdate(Cancel As Integer)
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