Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing multiple parameters from listbox on form to query 2

Status
Not open for further replies.

TMCraig

Technical User
Jan 8, 2004
4
US
I am trying to use listboxes with multi select enabled on a form to filter records from a table. I have several listboxes, each for a different field that needs to be filtered.

What I want to do is allow the user to select multiple parameters from each listbox and any records that meet those parameters be displayed.

eg.. they could select "Toyota" and "Ford" from 1 listbox and "2-door" from another listbox and all 2-door Toyotas and Fords would show up, but no Chevy's or 4-doors because those weren't selected.

Thanks.

I am able to use the following in the query criteria when multi select is not enabled-
[Forms]![formname]![listboxname]
The problem is getting the query to filter multiple parameters.

 
You'd have a better chance at getting an answer if you posted this question in a more appropriate forum. This looks like a language problem to me, and you haven't even given a clue to what that might be.
 
What you are attempting to do is capture the values of a listbox that can allow mulitiple instead of single selection of values and then uses those values as the criteria for your query.

This is a bit complex because it involves capturing the values of the ListBox list property and then manipulating that list so it can be understood as valid SQL syntax by Access.

I'll see what I can find to help you or I may have to build a quick sample DB to insure what I am posting here will be correct unless someone else already has the solution handy.
 
TMCraig,


Here is a small step in helping you get where you need to be.

If you add the following code to a Click event of a button and change it so your listbox is referenced you will see what values are being captured.

The next step would be get the formatting of these values passed to a query as parameters.


Dim strItems As String

For intCurrentRow = 0 To List0.ListCount - 1
If List0.Selected(intCurrentRow) Then
strItems = strItems & List0.Column(0, intCurrentRow) & " "
End If
Next intCurrentRow
MsgBox (strItems)
 
The following post should help you with your problem...

thread702-563930

"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Thank you for the help. I have a working version of what I need to do now. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top