Filter an Access Subform by Two Dates on a Main Form
Question details
Filter overtime records in a subform using start and end dates selected on the main form.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- An administrator selects a date range on a main form and wants the subform to show overtime records whose start and end dates fall within that range.
- Observed behavior
- The desired result is a subform that updates when either date changes and supports a blank start or end date.
Identify the names of the main form, its two date controls, the subform control, and the overtime table or query fields. The example assumes each record's start date is no later than its end date and that the main-form date controls contain dates without time values.
Filter the subform query and requery it after date changes
Use main-form controls as optional query boundaries, then refresh the subform whenever either control changes.
The example includes records that start on or after the selected start date and end on or before the selected end date. Using a less-than comparison with the next day includes all times on the end date.
Replace AdminForm, txtStartDate, txtEndDate, OvertimeRecords, StartDate, EndDate, and subOvertime with your actual object, control, and field names. AdminForm must be open when the query runs.
Open the subform in Design View, open its Property Sheet, and find Record Source on the Data tab. Open the query builder and switch to SQL View.
Adapt this SQL to your table or existing query: SELECT * FROM OvertimeRecords WHERE (Forms![AdminForm]![txtStartDate] Is Null OR [StartDate] >= Forms![AdminForm]![txtStartDate]) AND (Forms![AdminForm]![txtEndDate] Is Null OR [EndDate] < DateAdd("d", 1, Forms![AdminForm]![txtEndDate])); Save the query or record source.
Open the main form in Design View. In the Property Sheet for each date control, select the Event tab, choose After Update, and use the builder to create an event procedure containing: Me![subOvertime].Form.Requery
Open AdminForm in Form View and enter both dates. Change or clear each date control to confirm that the subform refreshes and that a blank boundary does not restrict that side of the range.

Review exported overtime records in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface and Excel format compatibility for moving spreadsheet work across. Export Access records to Excel if you want to review and filter them in WPS Spreadsheets; WPS does not replace the Access subform or fix its query.

Frequently Asked Questions
What happens if I leave one date control blank?
The query's Is Null check removes that boundary. With both controls blank, neither date boundary restricts the records.
Does the filter include records on the end date?
Yes. The query uses EndDate < DateAdd("d", 1, the selected end date), so it includes times throughout the selected end date when the date control has no time value.
Why doesn't the subform refresh after I change a date?
In the main form's Design View, check the After Update event for both date controls and confirm that Me![subOvertime].Form.Requery uses the actual subform control name.
How can I show records that overlap the selected range instead?
For an overlap filter, compare the record's EndDate with the selected start and its StartDate with the selected end. For inclusive date boundaries, use EndDate >= the start control and StartDate < DateAdd("d", 1, the end control), with an Is Null check for each optional boundary.
Can I review the Access records in WPS Spreadsheets?
Yes. In Access, export the table or query using External Data > Export > Excel, then open the resulting workbook in WPS Spreadsheets. This creates a spreadsheet for review; it does not preserve the live Access subform filter.




