Help me with some code or method please

Ste4en

Registered User.
Local time
Today, 12:11
Joined
Sep 19, 2001
Messages
142
I posted this Q on the VBA board but no answers – So I am reposting here….

I have a database which reads data from a table in a handscanner database for time in and out of work. I have to link to a payroll system and so unable to use the handscan software to do what I need.

The scanner provides 2 lines of raw data per employee each day - see example below. I use the Max of punchfield for the Out time and Min of punchfield for the In time. This is done by a query which has been working flawlessly for sometime, however we have introduced a second shift ending after midnight and so there are some difficulties because the out time is now the Min of Punchfield on the following day.....

The punch data that I get is in minutes which are zeroed at midnight. So my data will be as follows:

Typical Day Shift - Shift 1

01/20/02 JoeDayWorker; Punch 360
01/20/02 JoeDayWorker; Punch 960

From this the time of entry was 360 minutes after midnight on 01/20/02 i.e. 6am and that he left 600 minutes later at 960 minutes after midnight i.e. 4pm on 01/20/02.

For any date & name I query the data and select MinofPunch as the In Punch and MaxofPunch as the Out Punch. Each person is designated to shift 1 or 2 in the roster.


Typical Night Shift - Shift 2

01/21/02 JoeNightWorker; InPunch 1080
01/22/02 JoeNightWorker; Outpunch 240

He arrived at 6pm and leaves the following morning at 4am.

Following the same rules as for shift 1 would provide that he clocked in at 4am and went home at 6pm. The time difference is correct but it is based on the wrong pair of punches as we would find out on Monday when there would be no out punch for the Sunday night when we don't work.

So my plan was, when the shift = 2 to use the Max Punch of
[ReportDate] as the in Punch and the Min Punch of the [Report Date]+1 (tomorrow) as the outPunch. This way I would be reading the correct In and Out Punch pair.

Code something like this ...

If shift = 1 then
PunchDate = ReportDate
InTime = MinofPunchTime
Outtime = MaxofPunchtime

else '(shift=2)
PunchDate = ReportDate
InTime =MaxOfPunchTime

PunchDate=ReportDate+1
OutTime=MinofPunchTime

End if

My problem is I don’t know how to write this in code or where to put the code. Is it a public or private function or sub and how do I call this from a query.

Any help appreciated.

Many thanks
Steve
:confused:
 
Steve,

If OutPunch > InPunch Then
intMinutes = OutPunch - InPunch
Else
intMinutes = (2400 - InPunch) + OutPunch
End IF


I don't know where you'd put it, but that should
work unless somebody works over 24 hours.

Wayne
 
My problem is not calculating the interval between the in and out punch - it is specifying the correct pair of punches on which to perform the interval calculation.

A day shift has an in and out punch on the same day. Minutes on site is the difference between the two punch values.

A night shift has an inpunch on one day and and out punch after midnight so the next day. So I need to tell something to select the maxofpunch for the 1st day and the minofpunch for the 2nd day.

So if I am running a report for yesterday when shift = 2 select the inpunch (maxofPunch) for yesterdays date and MinofPunch for todays date. Then calculate the minutes on site.

Hope that clarifies.
thanks
 

Users who are viewing this thread

Back
Top Bottom