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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using List Box to set Filter Criteria in a Query 1

Status
Not open for further replies.

jennilein

Technical User
Mar 17, 2003
63
US
I have a list box that I would like to use for selecting multiple criteria to be used in a query. It works now with only 1 selection. If I change the multiselect property of the list box to extended - the query doesn't work - it always returns nothing.

How can I use the list box for selecting query criteria using "or" - not "and"?

Thanks.
 
Tag property: Where=[12 Month Table].[salescode],String;


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Right, because you don't have your Tag property set correctly. Think about it this way. Suppose you were going to create you SQL statement with the where clause included (forget about the list box for now). Your SQL statement would then look like this:

SELECT [12 Month Table].[salescode], [12 Month Table].partid FROM [12 Month Table] Where [12 Month Table].[salesCode] IN('1P010','1P015') WITH OWNERACCESS OPTION;

Consequently, your Tag Property should look like this:

Where=[12 Month Table].[salescode],string;


 
For some reason, it's not opening my report in print preview anymore...it's trying to print each time. Is OpenReport the wrong command?
 
DoCmd.OpenReport "rpt_test", acViewPreview, , BuildWhere(Me)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ooops! Did it from memory. When back and looked at the example in my FAQ. Should be this

Docmd.OpenReport "rptYourReport",acViewPreview,,BuildWhere(Me)
 
Okay, that worked.

However, when I try to run it, I keep getting an "Enter Parameter Value" box?

It's like it's not recognizing my selections.
 
Thank you all for your help. It finally works!

However, isn't there a way to tie the list box selections into my query directly? If I nest other queries off that query, it doesn't recognize the selections being made in the list box on the form. It only works for that 1 query and only when I run the report.

Any thoughts?

Thanks again for all you patience with me the other day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top