Adding Fields

MS_Access_Amature

Registered User.
Local time
Today, 03:21
Joined
Nov 10, 2010
Messages
56
I have 2 tables:
TimeSheet Table
Employees Table

The Employee Table is for when an employee clocks in and clocks out just for that day.

The TimeSheet Table saves all the data (hours an employee worked) so when i make a report you can go back to whatever specific day you want to go back to.

In the form when they click clock in, that time saves in the employees table in the clock in field. Then when they click clock out, that time saves in the employees table in the clock out field. And that's it for that table.

When you save the employee table i want that time worked that day to be added up and saved in the TimeSheet table in the TotalTime Field.

How can i do this?
 
It could be done in the click event of the clock out button, but I don't see the point of the timesheet table. You can always calculate/summarize the hours from the first table based on their activity (I'm assuming that table contains records for each day). You don't want to try and maintain the same data in two places.
 
The TimeSheet Table is to store all the data. Which will include hours worked that day, that week, that month, etc. But Yeah, you're right, I'm going to just save everything into the TimeSheet Table...but how can i add the hours up using code. Like for example if the user clicks clock in the time saves in the clockin field and then it saves in the clockout when he clicks that button...thats just for that day. So how can i get those hours and add them up so they can be stored and added up for the week, month, etc??

What Im trying to basically do is a program to punch in punch out of work and for it to store the hours and do reports.
 
Hopefully you're storing date/time rather than just time. It will be easier if you have times spanning midnight. I'm also assuming you have a record for each in/out. In a query, you can either subtract the start from the end, or use the DateDiff() function to calculate a standard unit of measure between the two (number of minutes for example). If you change the query to a totals query (icon that looks like an E), you can sum that calculation. You can then format the result to display how you want on a form/report.
 
i think you need at least one other table

this is one occasion when i would denormalise by having a hours summary table, based on whatever pay period you use (or maybe daily) to summarise the timesheet table.

a) dont they clock in/out several times a day?
b) what if they never clock out due to error?
c) is the time sheet data naturally a dbs table, or is it a csv or fixed width file

I would import the time sheet data , validate it, and store the daily summaries into the internal summary table.

but you need to analyse exactly how far you are going, and get ther table structure right before you go a lot further.
 
Why doesn't clock in and clock out save in the same line?

For example, say i sign in with employee 3. When i click clock in it saves in TimeID 1 and when i click clock out it saves in TimeID2. I want it to save in the same line so i can add them up and have a TotalTime Field.
 
That will be a hard question to answer without seeing the application.
 
Private Sub Button_In_Click()
Button_ViewInfo.SetFocus
Me.Button_Out.Enabled = True
Me.Button_In.Enabled = False
DoCmd.SetWarnings False
DoCmd.RunSQL "insert into TimeSheet ([TimeIn]) Values (Now)"
DoCmd.SetWarnings True
End Sub




timesheet.png
 
Last edited:
Well, this SQL is designed to add a new record:

DoCmd.RunSQL "insert into TimeSheet ([TimeIn]) Values (Now)"

If you're doing the same thing on the time out, that would explain it. There must be something else going on though, as your code is not adding the EmployeeID, but it is there.
 

Users who are viewing this thread

Back
Top Bottom