totn Access

MS Access 2003: Filter a query based on data entered in a text box

This MSAccess tutorial explains how to filter a query based on data entered in a text box in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, need to search for all Usernames containing 'ahm'. I want to create a form with a text box and a button. In the text box, I want to enter the search criteria and then click on the button to open the query displaying only the results where the Username field contains the value entered in the text box.

How can I do this?

Answer: We've created an example that you can download.

Download version in Access 2000 (as demonstrated below)

First, we've created an Access form with a text box called txtCriteria where search criteria can be entered.

Microsoft Access

When the user clicks on the Run Query button, the query called "qryEntries with Search Criteria" will open displaying all records where the Username field contains the value entered in the text box.

In this example, we entered 'ahm', so the query displays all records where the Username field contains the string 'ahm'.

Microsoft Access

If we take a quick look at the Design of the query, you can see that we use the LIKE condition to filter the results.

Microsoft Access