totn Access

MS Access 2007: Create a form where you can perform searches and display search results

This MSAccess tutorial explains how to create a form where you can perform searches and display search results in Access 2007 (with screenshots).

Question: In Microsoft Access 2007, I'd like to be able to create a form that allows me to perform searches. First, I want to enter a search string and then click on a button to return all records that contain that search string. I should then be able to scroll through these records.

Answer: We've provided a download to demonstrate how you can set up search functionality.

Download version in Access 2007

First, we've set up a form where the user can enter a search string. In the example below, we've entered "store" as the value to search for in the CompanyName field.

Microsoft Access

When the Search button is pressed, the following message box will appear:

Microsoft Access

Your form will then display the search results as follows:

Microsoft Access

Please note that this method of searching is achieved by using a form and a subform.

Pay close attention to how the RecordSource is set on the form called frmCustomers_sub. The RecordSource on this form is updated using VBA code and not in the Properties window.

We've also included a "Show all customers" button in case you wish to view all customer records.