Part IV: Professional Database Development
890
The Chapter25.accdb database contains a parameter query named qryProductParameter-
Query.
The simplest way to create a parameter query is to create a select query, specify the query’s criteria,
and run the query to make sure it works. Then change the criteria to the following:
Like [<some prompt>] & “*”
or:
Like “*” & [<some prompt>] & “*”
where <some prompt> is the question you want to ask the user. Figure 25.7 shows a parameter
query that prompts the user whenever the query is run to enter the Product Category.
FIGURE 25.7
Creating a simple parameter query
Anytime the query is run, even if it’s used as the record source for a form or report or the row
source for a list or combo box, the parameter dialog box is displayed — and depending on what is
entered, the query criteria filters the query results. Figure 25.8 shows the parameter dialog box
open, asking for the product category value required by the query.
You may remember learning that the Like operator allows for wildcard searches. For example,
if you want to filter the query records for any product category that starts with “car” (or “CAR”),
you enter CAR in the parameter dialog box. Without the parameter, you would have to enter
Like “CAR*” in the criteria area of the query. Also, because the wildcard (*) is included as part
of the parameter, users don’t have to include the wildcard when they respond to the parameter
dialog box.