Others

How to Create an Optional Date Range Filter in an Access Query

Muhammad TalhaMuhammad Talha Nov 2, 2026 869 views

Question details

The user needs to create an Access query that filters records based on optional start and end dates provided in a form, ensuring all records are returned if the date controls are left blank.

How to Create an Optional Date Range Filter in an Access Query
Product
Microsoft Access
Device & OS
not provided
Scenario
Filtering records in a database query via form controls where the date criteria are not strictly required for the query to execute.
Observed behavior
The query must successfully return filtered records if dates are entered, or automatically bypass the filter and return the full dataset if the date controls remain empty.
Before you start

Ensure you have the exact names of your form controls (e.g., [Start Date] and [End Date]) and the target table field (e.g., [Opened Date]) ready before modifying your query criteria.

Solution 1Recommended

Add an 'IS NULL' Check to the Query Criteria

This is the most straightforward method to handle optional parameters directly within the Access Query Design or SQL view without relying on VBA.

By pairing your date criteria with an 'IS NULL' statement using the OR operator, Access will evaluate whether a date was provided. If the form control is blank, the IS NULL condition becomes true, and the filter is effectively bypassed for that field.

1
Open the Query in SQL View

In your Microsoft Access database, right-click your target query in the Navigation Pane and select 'Design View'. From the ribbon, click the 'View' button drop-down and select 'SQL View'.

2
Locate the WHERE Clause

Find the section of your SQL statement that begins with 'WHERE'. If your query doesn't have one yet, you will add it right before the semi-colon at the end.

3
Insert the IS NULL Logic

Modify or add the WHERE clause to include the null checks for both start and end dates. Use the format: WHERE ([Opened Date] >= [Forms]![YourFormName]![Start Date] OR [Forms]![YourFormName]![Start Date] Is Null) AND ([Opened Date] <= [Forms]![YourFormName]![End Date] OR [Forms]![YourFormName]![End Date] Is Null).

4
Requery the Form on Update

Open your filtering form in Design View, select the Date text boxes, and open the Property Sheet. Under the 'Event' tab, add a macro or VBA code to the 'On After Update' property containing the command to requery the form or listbox (e.g., Me.Requery).

Parentheses are crucial: Always enclose the OR conditions in parentheses as shown above. Without parentheses, the AND/OR logic will evaluate incorrectly and return unintended records.
Free Microsoft Office alternative

Manage Your Data Easily with WPS Office

While Microsoft Access is a powerful database tool, many complex data tracking and filtering tasks can be easily managed using spreadsheets without writing SQL queries. WPS Office provides a lightweight, highly compatible, and completely free alternative to Microsoft Office, featuring robust spreadsheet capabilities for all your daily data needs.

  1. 1. Download and Install WPS Office: Visit the official WPS website to download the free suite and install it on your device.
  2. 2. Open WPS Spreadsheet: Launch WPS Office and open a new Spreadsheet to begin organizing your dataset.
  3. 3. Use Built-in Date Filters: Select your data columns, click the 'Data' tab, and select 'Filter'. Click the drop-down on your date column to easily apply customizable date range filters visually.
Highly compatible with Microsoft Excel formats (.xlsx, .xls, .csv)Free and lightweight suite including Writer, Spreadsheet, Presentation, and PDF toolsFamiliar user interface ensuring seamless migration and no learning curvePowerful built-in Data Filtering, Sorting, and Pivot Table features without complex coding
microsoft office alternative - wps office

Frequently Asked Questions

Why does the BETWEEN operator fail in Access when one date is blank?

The BETWEEN operator requires both a defined start and an end value to evaluate successfully. If either value is Null (blank), the entire condition resolves to Null, which causes the query to filter out all records instead of showing them.

How do I force the query to update after I clear a date field?

You need to requery the data source. In your form's Design View, you can add a simple VBA command like 'Me.Requery' to the 'After Update' event of your date text boxes. This ensures the query re-evaluates the IS NULL logic immediately.

Can I use this optional filter method for text fields as well?

Yes. For text fields, you can use the exact same logic structure: [Field Name] = [Forms]![YourForm]![ControlName] OR [Forms]![YourForm]![ControlName] Is Null. You can also pair it with the LIKE operator and wildcards for optional partial text matching.