Others

How to Calculate Total Vacation Hours Through a Selected Date in Access

Elise WilliamsElise Williams Oct 23, 2026 868 views

Question details

The user needs to create a query to total employee vacation hours and management adjustments up to a specific date provided by an active form prompt.

How to Calculate Total Vacation Hours Through a Selected Date in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Calculating aggregate totals for employee vacation hours up to a dynamically specified date using a form parameter in an Access database.
Observed behavior
The query requires a proper SQL setup to filter dates based on form input before grouping the records to calculate the sum.
Before you start

Ensure that your Access database is open and the form containing your target date field (e.g., 'StartEnd-CONV') is running in Form View so the query can successfully read the date parameter.

Solution 1Recommended

Use SQL View to Filter and Group by Date

This is the most direct method to ensure your date criterion is processed before the aggregate grouping occurs in your query.

To properly calculate totals up to a specific date, the date criterion must be placed in the WHERE clause before the GROUP BY clause. This ensures Access filters the records by your form's date parameter first, and then sums the remaining values.

1
Open Query Design

Navigate to the 'Create' tab on the Access ribbon and click on 'Query Design'. Close the 'Show Table' dialog without adding any tables.

2
Switch to SQL View

Click the 'View' button on the left side of the ribbon and select 'SQL View' from the dropdown menu.

3
Enter the SQL Statement

Type the following SQL code, replacing table and field names with your own: SELECT EmployeeID, Sum(VacHrs) AS TotalVacation, Sum(ManagementAdj) AS TotalAdjustments FROM Attendance WHERE DateAbsent <= [Forms]![StartEnd-CONV]![txtEnd] GROUP BY EmployeeID;

4
Run the Query

Make sure your form ('StartEnd-CONV') is open and has a valid date in the 'txtEnd' textbox. Click the 'Run' (!) button in the ribbon to view the aggregated results.

Use SQL View to Filter and Group by Date
Parameter Matching: Ensure the form name and control name in your SQL string perfectly match the actual names used in your Access database.
Free Microsoft Office alternative

Manage and Analyze Employee Data Easily with WPS Office

While Microsoft Access is a powerful tool for complex relational databases, managing employee records and tracking vacation hours can often be done more intuitively in a spreadsheet. WPS Office offers a free, lightweight, and highly compatible alternative, allowing you to use functions like SUMIFS to instantly total hours through a selected date without writing complex SQL queries.

  1. 1. Download and Install WPS Office: Get WPS Office for free from the official website and install it on your device.
  2. 2. Import Your Data: Export your Access attendance table to an Excel format and open it seamlessly in WPS Spreadsheet.
  3. 3. Use the SUMIFS Function: Instead of building SQL queries, use a formula like =SUMIFS(VacationHours, EmployeeID, "Emp01", DateColumn, "<="&TargetDateCell) to instantly get your totals.
Free and lightweight alternative to Microsoft OfficeSeamlessly open, edit, and save Microsoft Excel (.xlsx) filesEasily calculate conditional totals using advanced formulas like SUMIFSUser-friendly interface with zero learning curve for Office users
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Access query prompt me to enter a parameter value instead of reading the form?

This happens if the form referenced in your query is closed, or if there is a typo in the form name or control name within your SQL statement. Ensure the form is open in Form View and verify the spelling of [Forms]![FormName]![ControlName].

Can I calculate vacation totals between a specific start and end date?

Yes. If you need to specify a date range rather than just an end date, use the BETWEEN operator in your WHERE clause. For example: WHERE DateAbsent Between [Forms]![FormName]![txtStart] And [Forms]![FormName]![txtEnd].

Why does my query return an error when I use GROUP BY with a date criteria?

In SQL, the WHERE clause must be placed before the GROUP BY clause to filter records before they are aggregated. If you are using Design View, ensure the 'Total' row for the date field is set to 'Where' rather than 'Group By'.