How to Create an Optional Date Range Filter in an Access Query
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.

- 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.
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.
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.
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'.
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.
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).
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).
Build a Dynamic WHERE Clause using VBA
Ideal for complex search forms with multiple optional filters, this method generates the SQL filter dynamically so that only the populated fields are applied.
Set Default Form Values using DMin and DMax
Use default values to define the boundaries of your dataset so the query receives valid dates even when the user leaves the fields blank.
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. Download and Install WPS Office: Visit the official WPS website to download the free suite and install it on your device.
- 2. Open WPS Spreadsheet: Launch WPS Office and open a new Spreadsheet to begin organizing your dataset.
- 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.

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.




