Multi-Select List Boxes

E

Erna Henderson

I have a form with a multi select list box, two date range
boxes, and a preview report command button. I want to
pass the one or more items selected in the multi select
list box along with the from and to date ranges to my
query which opens the report. I have the access
web "Forms: Use Multi-Select List boxes as query
paramaters" but am getting errors using the code (see
below) that access cannot find the fields referenced and I
am not sure how to transfer the variable strSQL to my
query once it is concatenated. Any additional help you
can provide would be appreciated.

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL as String
Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox
strSQL = "Select * from Employees where [EmpID] = "
For each varItem in ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & " OR
[EmpID}="
strSQL = left$(strSQL,len(strSQL)-12)
 
Top