totn Access

MS Access 2003: Create a parameter query that performs a wildcard search

This MSAccess tutorial explains how to create a parameter query that performs a wildcard search in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, I'm trying to build a parameter query that allows the user to input desired text, and the query will return all records that CONTAIN that text.

Answer: You can create a parameter query that utilizes a wildcard search as follows:

First create your query.

Microsoft Access

Then enter your parameter using the LIKE clause and the special "*" character, since you want to perform a wildcard search. Parameters should be enclosed in square brackets as follows:

Like "*" & [Search text] & "*"

This will create a parameter called [Search text]. So that only those records from the Product_Info table will be returned where the Notes field contains the text that you enter as a parameter.

Next, you probably want to ensure that the user enters a text value. To do this, select Parameters under the Query menu.

Microsoft Access

When the Query Parameters window appears, enter the parameter called [Search text], and select Text as the data type. Click on the OK button.

Microsoft Access

Now, when you run the query, you will be prompted to enter the "Search text".

Microsoft Access

In this example, we've entered the value "forms". So the query will only return those records where the Notes field contains the phrase "forms.

Microsoft Access