Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 25: Advanced Data Access with VBA


891


FIGURE 25.8

Running the parameter query


Tip
You can use the wildcards * (anything after this position) and? (one character in this position) with a Like
operator in any query or SQL string.


Note
If SQL Server Compatible Syntax (ANSI 92) is selected (File ➪ Options, then select the Object Designers tab),
or if ADO is being used to run the SQL statement, the wildcards are % (anything in this position) and _ (one
character in this position)


A consequence of adding the asterisk to the parameter is that, if the user doesn’t enter a parameter
value, the criteria evaluates to “LIKE *”, and the query returns all records. Leaving the asterisk
out of the criteria expression results in no returned records if the user fails to provide a product
category.

Figure 25.9 shows the Query Parameters dialog box (opened by right-clicking the query’s upper
area and selecting Parameters from the shortcut menu). You use the Query Parameters dialog box
to specify parameters that require special consideration, such as date/time entries or specially for-
matted numbers. One text entry has been entered in the Query Parameters dialog box to show how
it works. You enter the parameter text and choose the parameter’s data type.
Free download pdf