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

Filtering a query using a combo box 1

Status
Not open for further replies.

adherennium

IS-IT--Management
Sep 26, 2002
5
GB
Hi,

Does anyone know how I can set up a query to filter using a combo box, for example a list of customer names, so that if one name is selected only those records pertaining to that customer are show, BUT if no customer is selected then all customer records are shown?

I want to be able to filter on about 5 different optional criteria and writing a separate slightly different query and report for each one seems inefficient.

Thanks in advance.

Rob
(adherennium)
 
Hi,
On the form you will use to run your query, create combo boxes for each criteria you wish to use. Populate them with appropriate Union query like this:

Select "*" from Customers UNION (SELECT DISTINCT Customers.CompanyName
FROM Customers
ORDER BY Customers.CompanyName);

This put a star at the beginning of your list. That will show, when selected, all data.
In the criteria of your query, put, all on the same line, the combo name that has the information for that field.

Forms![MyForm]![Combo45]



Jean-Paul
Montreal
jp@solutionsvba.com
 
Thank you for this simple and elegant solution. Very much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top