jlbillingsley
asked on
Calculate Weekly Payroll Hours
I have a payroll form with employees & their time in(emp1ti) & time out(emp1to) that is filled out daily. I have an expression to calculate an employee's daily hours minus 1/2 hour for lunch in the control source property of a box used just for display: =(DateDiff("n",[emp1ti],[e mp1to])/60 )-0.5
I need to also display total weekly hours on the form. I have a table field (emp1twh) that I would like to write the daily time as an integer to. I would like to add to that field every day's daily hours until it is Monday again, then overwrite the field. The new value should be displayed as soon as the new timein and timeout are entered. I have the following psuedo code, but am unsure where to put it and how to update my table field:
If DatePart("d", emp1ti[,2]) = 2
Then emp1twh=(DateDiff("n",[emp 1ti],[emp1 to])/60)-0 .5
Else
emp1twh=emp1twh+((DateDiff ("n",[emp1 ti],[emp1t o])/60)-0. 5)
Any help is much appreciated. I am new to VBA.
Thanks,
jessica@tridewb.com
I need to also display total weekly hours on the form. I have a table field (emp1twh) that I would like to write the daily time as an integer to. I would like to add to that field every day's daily hours until it is Monday again, then overwrite the field. The new value should be displayed as soon as the new timein and timeout are entered. I have the following psuedo code, but am unsure where to put it and how to update my table field:
If DatePart("d", emp1ti[,2]) = 2
Then emp1twh=(DateDiff("n",[emp
Else
emp1twh=emp1twh+((DateDiff
Any help is much appreciated. I am new to VBA.
Thanks,
jessica@tridewb.com
My employees got 45 minutes for lunch.
Yours would be 00:30:00" AS Lunch
Alan :)
Yours would be 00:30:00" AS Lunch
Alan :)
SELECT [tblTimeClock].[emp1ti], [tblTimeClock].[emp1to], Format(DateAdd("s",DateDif f("s",[emp 1ti],([emp 1to])),(Da te())),"hh :nn:ss") AS Hours, "00:30:00" AS Lunch, Format(DateAdd("s",DateDif f("s",[emp 1ti],([emp 1to])),(Da te()-#12/3 0/1899 0:30:0#)),"hh:nn:ss") AS emp1twh
FROM tblYourTable;
FROM tblYourTable;
A very good solusion Alan. Mike
ASKER
Where does this go? I keep getting a syntax error.
Hi Jessica,
If you want to use it as a calculated field in a report or form add this to the controlsource property for the calculated field.
=Format(DateAdd("s",DateDi ff("s",[em p1ti],([em p1to])),(D ate()-#12/ 30/1899 0:30:0#)),"hh:nn:ss")
If you want to include it in the form or reports recordsource you need to edit the recordsource for the form or report by clicking the build button [...] alongside the Record Source property in the form/report properties dialog.This will invoke a query builder based on the current recordsource.
To add a calculated field in query design view, in a new field add:
emp1twh: Format(DateAdd("s",DateDif f("s",[emp 1ti],([emp 1to])),(Da te()-#12/3 0/1899 0:30:0#)),"hh:nn:ss")
Then set the controlsource of your calculated field in your form/report to: emp1twh
If you are still having difficulty, thats OK, just let me know and we can take this one step at a time from the top.
Initially we aim to provide a quick response, treating questions with greater points associated with greater urgency. I am more than willing to walk through this with you.
Alan :)
If you want to use it as a calculated field in a report or form add this to the controlsource property for the calculated field.
=Format(DateAdd("s",DateDi
If you want to include it in the form or reports recordsource you need to edit the recordsource for the form or report by clicking the build button [...] alongside the Record Source property in the form/report properties dialog.This will invoke a query builder based on the current recordsource.
To add a calculated field in query design view, in a new field add:
emp1twh: Format(DateAdd("s",DateDif
Then set the controlsource of your calculated field in your form/report to: emp1twh
If you are still having difficulty, thats OK, just let me know and we can take this one step at a time from the top.
Initially we aim to provide a quick response, treating questions with greater points associated with greater urgency. I am more than willing to walk through this with you.
Alan :)
SELECT Table.id,sum(([Table]![emt 1to]-[Tabl e]![emp1ti ])*24 - 0.5) AS Expr1
FROM Table
where table.id = 1
group by table.id;
FROM Table
where table.id = 1
group by table.id;
ASKER
Maybe I wasn't clear in my original question. This appears to calculate only the hours between the employee's time-in & time-out. My expression takes care of this. I also like that my expression returns an integer number. The part I need assistance with is a running total of total weekly hours worked on the form. I want to add to the total weekly hours field until it is Monday again, and then I want to overwrite the field and start over. I have the following pseudo code:
My fields are emp1ti(employee time in), emp1to(employee time out), and emp1twh(employee total weekly hours)
If DatePart("d", emp1ti[,2]) = 2
Then emp1twh=(DateDiff("n",[emp 1ti],[emp1 to])/60)-0 .5
Else
emp1twh=emp1twh+((DateDiff ("n",[emp1 ti],[emp1t o])/60)-0. 5)
Thanks!
My fields are emp1ti(employee time in), emp1to(employee time out), and emp1twh(employee total weekly hours)
If DatePart("d", emp1ti[,2]) = 2
Then emp1twh=(DateDiff("n",[emp
Else
emp1twh=emp1twh+((DateDiff
Thanks!
ASKER
If it's Monday, (start over) write the integer difference between employee time in and employee time out minus 1/2 hour for lunch.
Otherwise, add what already exists in that table field: employee total weekly hours, to the integer difference between employee time in and employee time out minus 1/2 hour for lunch.
Otherwise, add what already exists in that table field: employee total weekly hours, to the integer difference between employee time in and employee time out minus 1/2 hour for lunch.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Jessica,
You can drop this line I was using it for testing, I created a temp field in the table to calculate hours on a daily basis:
Me.emp1tdh = (DateDiff("n", [emp1ti], [emp1to]) / 60) - 0.5
Alan
You can drop this line I was using it for testing, I created a temp field in the table to calculate hours on a daily basis:
Me.emp1tdh = (DateDiff("n", [emp1ti], [emp1to]) / 60) - 0.5
Alan
Something like this may do:
SELECT [tblTimeClock].[IN], [tblTimeClock].[Out], Format(DateAdd("s",DateDif
FROM tblTimeClock;
Just change the fieldnames:
IN > emp1ti
Out > emp1to
tblTimeClock > YourTable
Alan :)