Access create search Form

This Access tutorial explains how to create a search Form with multiple criteria.

You may also want to read:

Access DoCmd.OpenForm Method to open Access Form

Access Combo Box value depends on another Combo Box

Return Access Form input to Access Report or Form or Query

Access create search Form with multiple criteria

Sometimes you need to create a search Form where users can select specific criteria. The simplest solution is to directly filter data for each field like using AutoFilter in Excel, but this is not elegant at all.

Access provides a Form Function called Filter by Form which is very easy to use.

Select a Table/Query > Create > Form > Apply Filter/Sort


Now you can select multiple criteria, you can even select a value from dropdown box. However those values of dropdown boxes are independent of each other.

You can also use Or criteria by clicking the Or tab.


When you selection is done, click on Toggle Filter


A better way to do filtering is for users to choose from dependent dropdown boxes.

For example, in the first dropdown box, users choose department A, and then in the second dropdown box,  users can view a list of person of department A.

This article will show you how to do such filtering.

Create a result Form

Assume that we have a Query as below. Our goal is to allow users to select department to show employee information, or select department + employee ID.

We are going to make a “result Form” that shows the search result.

Department Employee ID Employment Date Salary Allowance
Account 1 1/1/2000 10000 100
Admin 2 1/1/2001 20000 200
Admin 3 1/1/2002 30000 300
Admin 4 1/1/2003 40000 400
Payroll 5 1/1/2004 50000 500
HR 6 1/1/2005 60000 600

Click on the Query and the under Create tab, select More Forms > DataSheet


Now save the Form as result_frm. In case you would accidentally change the result data, you should change the Locked Property of each Text Box to Yes


In this example, I want to return all fields of Query1 in Result Form. I choose DataSheet because each record can be displayed in one row with horizontal scroll bar. I don’t prefer to use Continuous Form or Single Form because each record is displayed in several rows.

Create a Search Form

Create a blank Form and then add two Combo Boxes (Combo_Dept, Combo_EmpID) and one button (search_btn) as shown below.


1) Click on Combo_Dept, in the Row Source property, type


Row Source is what you can select in the ComboBox.

2) Click on Combo_EmpID, in the Row Source property, type

SELECT [Employee ID] FROM Query1 WHERE [Department]=[forms]![search_frm]![Combo_Dept];

3) Select Combo_Dept, select After Update Event and build the below Procedure

Private Sub Combo_Dept_AfterUpdate()
    Me.Combo_EmpID = Null
End Sub

As you select a Department, Combo_EmpID is reset to Null and then rerun the query

4) Right Click on search_btn and then choose Build Event

Private Sub search_btn_Click()
    If IsNull(Me.Combo_EmpID) Then
        searchCriteria = "[Department]='" & Me.Combo_Dept & "'"
        searchSQL = "Select * FROM Query1 where " & searchCriteria
        searchCriteria = "[Department]='" & Me.Combo_Dept & "' AND [Employee ID] =" & Me.Combo_EmpID
        searchSQL = "Select * FROM Query1 where " & searchCriteria
    End If
    DoCmd.OpenForm "result_frm", 3, searchSQL
End Sub

Now you have successfully created a simple search Form. After you have selected criteria in Search Form, once you click the search button, the Result Form will pop up and displays the result.

Outbound References

Wyman W
Wyman is a Business Analyst based in Hong Kong, specialized in creating custom Function and Sub solutions, and is proficient in report automation with Access.

He is also a:
- Microsoft Most Valuable Professional (Excel)
- Microsoft Community Contributor
- Microsoft Office Specialist
- Microsoft Specialist
- Microsoft Technical Associate
- Microsoft Certified Professional
- IBM SPSS Specialist

Leave a Reply

Your email address will not be published. Required fields are marked *