View Full Version : Parameter Query


AnnPhil
03-27-2002, 05:18 AM
I need a query that will allow a user to find a specific record but then sometimes the user whats all records returned. How do i write a parameter query that will handle both situations? For example, a query that contains store locations, the user types in a specific store name one time, the next time the user whats all stores listed.
Any help would be great!

KKilfoil
03-27-2002, 05:48 AM
Have a look at using filtering.

This built-in functionality does what you want and more.

AnnPhil
03-27-2002, 06:14 AM
I thought of that but the db is designed to hide the toolbars so they don't have any of the filter buttons. I was hoping to prompt the user for the information and then return the records.

David R
03-27-2002, 07:14 AM
Use the combo box wizard to create an unbound combo box. Select the third option, "Find a record based on the value I select...". This will go to the store in question without removing the other stores from the listing. If you actually want to limit the recordsource to what you choose, use something like this:
Me.RecordSource = "SELECT * FROM queryName WHERE StoreName = '" & Me.UnboundCombo & "'"

This assumes the field you're searching on is a text field. Remove the single quotes if it's numeric.

HTH,
David R

RV
03-27-2002, 08:33 AM
Use this:

SELECT * FROM <yourtable or yourquery>
WHERE StoreName = [Which storename]
OR [Which storename] Is Null;

If a user enters a storename, all rows for this specific storename are retrieved.
If a user enters nothing, all rows are retrieved.

Suc6,

RV

AnnPhil
03-27-2002, 02:55 PM
Thanks for all your suggestions. I tried the one from RV and it worked great. Thanks so much to everyone who answered my question. I just love this site!!!!