Weekly Time Report

Art Barnwell

New Member
Joined
Jun 26, 2003
Messages
22
I have an Access 2002 database that stores daily employee time records. The DB will replace a manual system that relies on Excel-based weekly time sheets. I need to be able to produce weekly time reports but I am stumped. The report needs to provide rows of employees on the left-side, daily (Monday thru Sunday) time details for a particular week in the center, and weekly subtotals on the right-side. I need a way to select a particular week, and then return time records for that week, and then find a way to subtotal the daily records.

I am completely stumped, any suggestions will be greatly appreciated. :oops:
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You should look at using a dynamically generated crosstab query as the recordsource for a report.

What does that mean?

First, look at crosstabs. Using the wizard is a good idea to start. See if you can manually reproduce what you need right now, being explicit about what timeframe you want to use.

Second, about the times. You have to be careful how you specify times. Putting # characters in front/behind are mandatory.

Third, dynamically. Use VBA behind the form to generate the crosstab query by extracting values from a text-box or combo-box. When creating a combo-box control, you get the option to either extract fields from a table, or to manually type the values. My thought is, what you really want to do is specify options like 'current week', 'prior week' or something like that.

Your VBA needs to use functions like Date() (use VBA Access Help for options) to determine today, then figure out what 'current week' and 'prior week' means. Once it generates a range, you create a SQL query (the crosstab) and have it insert the values.

For example, this is a sample production crosstab query that I use.
The Crosstab is based off a Query that filters by date
Code:
{crosstab}
TRANSFORM Count(qryCount.[Car Number]) AS [CountOfCar Number]
SELECT qryCount.Yard, qryCount.LineOfRoad, Count(qryCount.[Car Number]) AS [Total Of Car Number]
FROM qryCount
GROUP BY qryCount.Yard, qryCount.LineOfRoad
PIVOT qryCount.Report;

{qryCount}
SELECT * FROM tblImpactsAll
WHERE (((tblImpactsAll.[Event Date])>#5/1/2003#));

When creating the date filtering query, what you could do is something like.

strSQL = "SELECT * FROM tblname WHERE [Event Date]> " & dteMyDate
-
And the last part. "As a recordsource for a report". Really, you have two options when telling a report what to use as it's recordsource. You can reference an existing table/query - or you can specify a SQL query as the recordsource. The former is a little easier, while the latter requires you to edit the Reports' recordsource property. Not hard, but a tiny bit more complex.

I'd recommend as a start, that create querydef's (allows you to create Queries that show up under the queries tab just like if you'd made them manually instead of from vba using...) You'd then specify that query as the default recordsource for the report (rather than attempting to modify the recordsource property) From there, for completeness, make sure the button that you hit that opens all this up opens the Report or does whatever it will need to do with it (email/save)

Code:
Dim dbs As Database
Dim qdf As QueryDef, strSQL As String

strSQL = "PROCEDURE Split; " _
     &  "SELECT * FROM tblname WHERE [Event Date]> " & dteMyDate

Set qdf = dbs.CreateQueryDef(qryname, strSQL)

This is a hodgepodge of several different types of tasks to create via code. As I mentioned, it's not necessarily the absolute best way to do this, but it would work and I tried to throw up things that were easier for me to learn to do.

Hope this points you in the right direction, or at least, gives you an idea where to go to figure out how you will end up doing it.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,575
Messages
6,160,603
Members
451,657
Latest member
Ang24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top