How to Make Access Query Criteria Optional When Form Fields Are Null
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.

- 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 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.
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.
Right-click your query in the Microsoft Access Navigation Pane and select 'SQL View' from the context menu.
Find the WHERE section of your SQL statement, which contains the current filtering criteria for your form parameters.
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.
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).

Configure Optional Criteria in Query Design View
Set up the OR conditions directly within the Access Query Design grid if you prefer a visual interface over writing SQL code.
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.

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).




