Multiselect Listbox to run Query

elsanto

Aspiring to Sainthood...
Local time
Today, 20:20
Joined
Jul 9, 2003
Messages
35
Hi all,

I've been browsing for a while now and can't figure out the solution to my problem.

I have query qryStatic returning records of transactions for various staff members from a number of combined tables. The query contains field StaffID

I have another table containing StaffID and StaffName, with a relationship between the StaffID of the table and query.

I want to have a list box with multi select = simple. Users select StaffName, click button, and run the query which displays records for selected staff.

So far I have the list box set up, with the criteria of my query looking at the list box. This works fine as long as I'm not selecting more than one record. As soon as I do, the query returns nothing.

I know I need to code something to tell it to return the records for the staff selected, but I don't know what the code is.

I'm so close, yet so far! It's killing me!
Any ideas?
Cheers.
 
For I = 0 To List0.ListCount - 1

If List0.Selected(I) Then
If List0.Column(0, I) = "All" Then
flgAll = True
End If
strIN = strIN & Chr(34) & List0.Column(2, I) & Chr(34) & ","
End If
Next I

'create the WHERE string, stripping off the last comma of the IN string
strWhere = "WHERE [LastName] In (" & left((strIN), Len(strIN) - 1) & " ) And ([tblLetters].[fldLtrPK] In(" & Me![txtLtrPK] & "))"

'if "All" was selected, don't add the WHERE condition
If Not flgAll Then
strSQL = strSQL & strWhere
End If

DBEngine(0)(0).Execute strSQL, dbFailOnError
 
Where does this specify the query or report to run?
 

Users who are viewing this thread

Back
Top Bottom