Microsoft Office Tutorials and References
In Depth Information
Reference Window | Creating a Parameter Query
• Create a select query that includes all fields to appear in the query results. Also choose
the sort fields and set the criteria that do not change when you run the query.
• Decide which fields to use as prompts when the query runs. In the Criteria text box for
each of these fields, type the prompt you want to appear in a message box when you run
the query, and enclose the prompt in brackets.
Now you can copy and rename the qryCustomersByName query, and then change its
design to create the parameter query.
To create the parameter query based on an existing query:
1. Open the Navigation Pane, copy and then paste the qryCustomersByName query,
renaming it qryCustomersByNameParameter .
2. Open the qryCustomersByNameParameter query in Design view, and then close
the Navigation Pane.
Next, you must enter the criteria for the parameter query. In this case, Sarah
wants the query to prompt users to enter the city for the customer records they
want to view. So, you need to enter the prompt in the Criteria text box for the City
field. Brackets must enclose the text of the prompt.
3. Click the City Criteria text box, type [Enter the city:] and then press the Enter
key. See Figure 5-15.
Figure 5-15
Specifying the prompt for the parameter query
prompt text
enclosed in brackets
4. Save and run the query. Access displays a dialog box prompting you for the name
of the city. See Figure 5-16.
Figure 5-16
Enter Parameter Value dialog box
You must enter a value so
that it matches the spelling
of a City field value in the
table, but you can enter
the value in either lower-
case or uppercase letters.
enter value here
The bracketed text you specified in the Criteria text box of the City field appears
above a text box, in which you must type a City field value. Sarah wants to see all
customers in Holland.
5. Type Holland , press the Enter key, and then scroll to the right, if necessary, to
display the City field values. The recordset displays the data for the seven custom-
ers in Holland. See Figure 5-17.
Search JabSto ::

Custom Search