Others

How to Make Access Query Criteria Optional When Form Fields Are Null

Kushani NimanthikaKushani Nimanthika Oct 26, 2026 868 views

Question details

The user needs to configure a Microsoft Access query to handle optional form field criteria, ensuring accurate results even when some input controls are left blank.

How to Make Access Query Criteria Optional When Form Fields Are Null
Product
Microsoft Access
Device & OS
not provided
Scenario
Filtering query results based on user input from a form where some parameter fields (like lower and upper ranges for IDs or contract numbers) might be empty.
Observed behavior
The query works correctly when all form fields contain values, but fails or returns incorrect results when one or more parameter controls are left blank.
Before you start

Before modifying your query, ensure that your form is saved and take note of the exact names of your form controls (e.g., [EmpIdFrom] and [EmpIdTo]) to avoid syntax errors.

Solution 1Recommended

Use Explicit Null Checks in SQL View

Modify your query's SQL statement to explicitly check if the form control parameters are Null, allowing the criteria to be bypassed when left blank.

A partial expression like 'Between [Form]![EmpIdFrom] And [Form]![EmpIdTo] Or Is Null' is incomplete and can cause logical errors. The parameter controls must be tested explicitly for Null using proper grouping.

1
Open Query in SQL View

Right-click your query in the Microsoft Access Navigation Pane and select 'SQL View' from the context menu.

2
Locate the WHERE Clause

Find the WHERE section of your SQL statement, which contains the current filtering criteria for your form parameters.

3
Add Explicit Null Checks

Modify your criteria to explicitly check for empty form fields. For a range, format it as: ([EmpId] Between [Forms]![FormName]![EmpIdFrom] And [Forms]![FormName]![EmpIdTo]) OR [Forms]![FormName]![EmpIdFrom] Is Null OR [Forms]![FormName]![EmpIdTo] Is Null.

4
Group Independent Criteria

Ensure each parameter group is tightly enclosed in its own parentheses and joined with the AND operator. This prevents a blank field in one category (like Employee ID) from bypassing the active filters in another category (like Contract Version).

Use Explicit Null Checks in SQL View
Syntax Tip: Properly grouped parentheses ensure your database engine evaluates the optional parameters correctly without breaking other query conditions.
Free Microsoft Office alternative

Need a Lightweight Office Suite? Try WPS Office

While Microsoft Access is a specialized database tool, managing exported data, reports, and daily documents is much easier with WPS Office. It provides a lightweight, highly compatible, and free alternative to Microsoft Office for your spreadsheets, documents, and presentations.

Seamlessly open, edit, and save Microsoft Office formats like .xlsx, .docx, and .pptx.Easily analyze and chart data exported from your Access databases using WPS Spreadsheet.Enjoy a familiar tabbed interface that requires zero learning curve.Lightweight design ensures smooth performance even on older devices.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my query return zero records when a form field is blank?

If your query criteria lack an explicit 'Is Null' check, Access treats the blank form field as an empty parameter and tries to find exact matches for nothing, resulting in zero records.

Can I use the 'Like' operator instead of checking for Null?

While using the syntax 'Like [Forms]![FormName]![ControlName] & "*"' works for some text fields, it is not recommended for numeric ranges, dates, or IDs. Explicitly checking for Null using 'OR ... Is Null' is a more robust and accurate method for all data types.

Why is my query ignoring other criteria when one field is left blank?

This usually happens due to missing or incorrect parentheses in your SQL WHERE clause. Ensure each parameter block is wrapped in parentheses and joined by the AND operator, for example: (Condition A OR Condition A is Null) AND (Condition B OR Condition B is Null).