Time & Attendance Access - Need to summarize data as of a specific date

Anonymous
2022-07-26T17:49:06+00:00

I have a db that maintains all employee's pto, adjustments, etc. in a single table.

Both time already taken and pre-scheduled time are logged in the same column (Date Absent).

The other 2 columns used will be Vac Hrs | Management Adj

I need to create a query/report that prompts for a specific date (dialog box entry) that will then look at 3 columns of data: Date Absent | Vac Hrs | Management Adj and find all transactions through that specific date (Date Absent) and total them (vac hrs, mgmnt adj) for each employee.

I already use the subtotal query to track everything logged but I now need to pull only some data.

Thank you - Leslie

Microsoft 365 and Office | Access | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2022-07-28T00:40:05+00:00

I may be overlooking something, but it seems the SQL order of statements is incorrect. GROUP should be after WHERE

SELECT EmployeeID, Sum(Attendance.VacHrs) AS TotalHrs
FROM Attendance
GROUP BY EmployeeID
WHERE DateAbsent Between Forms!StartEnd!txtStart AND Forms!StartEnd!txtEnd;

Proper order would be

SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments
Answer accepted by question author
ScottGem 68,845 Reputation points Volunteer Moderator
2022-08-05T20:16:41+00:00

What is {Through Date]? is it the date you enter into the form? If so then it should be

>=[Forms]![StartEnd-CONV]![txtEnd]

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments
Answer accepted by question author
ScottGem 68,845 Reputation points Volunteer Moderator
2022-08-03T17:00:47+00:00

Are you building your queries using Query Design mode or just writing SQL Statements?

If using Design Mode, then you enter < [Forms]![StartEnd-CONV]![txtEnd] in the WHERE row for the date column.

If writing SQL code, you have to include it in the WHERE clause of your query.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

38 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-07-27T18:33:12+00:00

    Hi Scott - thank you. The form is done and the query works until I add the last part. I keep getting syntax errors. I am missing an operator in this last line.

    Form is named StartEnd. This is what I have:

    WHERE DateAbsent Between Forms!StartEnd!txtStart AND Forms!StartEnd!txtEnd;

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,845 Reputation points Volunteer Moderator
    2022-07-26T23:07:58+00:00

    First, let me make sure I understand your table. It records the Employee ID, the date of absence, the amount of hours absent and any adjustments to the hours. Is that correct?

    If so, what I would do is create an unbound form with 2 text boxes; txtStart and txtEnd

    I would set the Default value of these as follows:

    txtStart: DMin("[DateAbsent]","tablename")

    txtEnd: DMax("[DateAbsent]",'tablename")

    Next create a Group By query like so:

    SELECT EmployeeID, Sum(VacHours) As TotalHrs

    FROM tablename

    GROUP BY EmployeeID

    WHERE DateAbsent Between Forms!formname!txtStart AND Forms!formname!txtEnd;

    gAdd a button to the form to run the query or a report bound to it.

    Since the Default values will include all the dates you don't have to change anything to get all the records. If you need to limit the date range, then enter the Start and/or End dates as needed.

    By the way, starting a new app for the next year is NOT good desing. There is no need for it as you can easily filter out records by period.

    Was this answer helpful?

    0 comments No comments