I need to build a query that asks for a record

G

Gina

I would like to build a query so that when you open it, it asks you for
information before it can open the query. I think it has something to do with
expression builder, but I'm not sure of the code.

Example: Clicking on the query then access asking you for product number.
You type it in then only those items appear.

Thanks in advance!
 
G

Golfinray

Parameter queries ask you to input information and uses that information in
the query. Read your help files for parameter queiries.
 
J

John W. Vinson

I would like to build a query so that when you open it, it asks you for
information before it can open the query. I think it has something to do with
expression builder, but I'm not sure of the code.

Example: Clicking on the query then access asking you for product number.
You type it in then only those items appear.

Thanks in advance!

Golfinray is correct: you need a parameter query. Fortunately they're easy.

You don't need the expression builder at all. Instead, just create a Query
selecting the fields that you want to see and to search. In the query grid, on
the Criteria line under the [Product Number] field, put

[Please enter product number:]

When you run the query you'll be prompted with the text between the brackets,
and the user's entry will be used as the criterion.

Better: create a little form frmCrit with a combo box selecting all the valid
product numbers (cboProduct let's call it). Use a criterion of

=[Forms]![frmCrit]![cboProduct]

Put a command button on frmCrit to open whatever Form or Report uses your
query; select the product, and click the button. Note that users should in
general never need to see a Query or a Query datasheet!
 
Top