Microsoft KB Archive/294954

= How to use the LIKE operator in parameter queries in Access 2002 =

Article ID: 294954

Article Last Modified on 8/19/2004

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q294954



Novice: Requires knowledge of the user interface on single-user computers.

This article applies only to a Microsoft Access database (.mdb).



For a Microsoft Access 97 version of this article, see 88671.

For a Microsoft Access 2000 version of this article, see 209823.



SUMMARY
This article shows you how to create a parameter query to search for all the records in a table that begin with, or that contain, a certain letter.



MORE INFORMATION
An easy way to search for records that begin with a certain letter is to create a parameter query that prompts for a character to search for. You can use the LIKE operator with the wildcard character (*) to accomplish this task. This example uses the Employees table in the sample database Northwind.mdb.

Method to Create Parameter Query Using the LIKE Operator
 Create a new query that is based on the Employees table. Drag LastName to the Field row and then type the following line in the Criteria row for the LastName field:

LIKE [Enter the first char to search by: ] & &quot;*&quot;

-or-

LIKE &quot;*&quot; & [Enter any char to search by: ] & &quot;*&quot;

NOTE: The Parameters dialog box is a fixed width dialog box; therefore, if the prompt is too long, not all of the characters will be displayed. When you run this query, you will be prompted with the message that you specified in the LIKE statement.

The first LIKE statement finds all the last names that begin with the letter that you type into the parameter prompt. For example, to find records where the last name starts with a &quot;L&quot;, type L and begin the search.

The second LIKE statement finds all the last names that have the letter that you type into the parameter prompt anywhere in the field. For example, to find records where the last name has a &quot;L&quot; anywhere in the field, type L and begin the search.

