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-08-03T16:04:39+00:00

    Hi Scott - thank you.

    This makes sense I am just not sure how. Could you please elaborate where and how this should be referenced in the other queries?

    1. I do name the macro's after testing is complete as I tend to have a few iterations before completion, but thank you def good advice.
    2. I am completely unfamiliar with procedure vs function.
    3. It does show in the On Click as an embedded macro in the properties, but that could still not be the proper way.
    4. Does this replace all the existing syntax or just some?

    Thank you!

    • the novice

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,845 Reputation points Volunteer Moderator
    2022-08-03T00:10:29+00:00

    OK, the answer to this is simple. You use the SAME criteria in the other queries.

    Since the form remains open. the other queries can reference the SAME control in the same syntax:

    Forms!formname!controlname

    So if you just need to reference the end date then

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

    A few other points.

    1. Use descriptive names for objects. Calling the function "Macro1" doesn't tell you what it does.
    2. Since you aren't returning a value, it shouldn't be a function but a procedure.
    3. it looks like you put the code in a Global Module, instead of the On Click event of the form
    4. You don't need to open a query when running a report. so all you need is to run the report So all you need is something like:

    Private Sub ButtonName_OnClick

    DoCmd.OpenReport "Final Date Report - CONV", acViewReport, "", "", acNormal

    End Sub

    Was this answer helpful?

    0 comments No comments