MS Access: Create a form where you can perform both text and numeric searches in Access 2003/XP/2000/97

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

First, we've set up the form which displays the Customer records. The user can click on the Search button to perform a search either on one of the text fields or one of the numeric fields in the Customers table.



When the Search button is pressed, the following form will appear:



The user can select the field to search, the operation to perform (such as contains), and then enter the value to search for. In this example, we've selected the "CompanyName" field, "contains" as the operation, and "store" as the value to search for in the "CompanyName" field.

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



Your form will then display the search results as follows:



You can also perform a numeric or mathematical search operation. For example, this time we've selected the "TotalSales" field, "is greater than" as the operation, and 5000 as the search value.



Now your form will then display the search results as follows:



Pay close attention to how the RecordSource is set on the form called frmCustomers. 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, and a "Generate Report" button to display a report of the search results.