D
Diarmuid
Hi
I have a client who enters employee Shifts. The 3 fields that mark a
shift as duplicate are if the TimeDate is the same, and the TimeStart and
TimeStop overlap. The code I'm currently using is also below, Seems easy,
but I've come across some problems. Best way is with some examples of the
problems. Assume all these are for the same date
CASE 1
Shift 1: 10:00 to 10:30
Shift 2: 09:00 to 11:00
Shift 2 won't come up as a duplicate, as the times are outside Shift 1.
CASE 2:
Shift 1: 22:00 to 08:00
Shift 2: 22:00 to 08:00
Here the problem is that Timestop is actually the next day.
I'm looking for an efficient way of checking, rather that just loads if
statements. Any ideas?
Thanks
Diarmuid
'***********************************************
stSQL = "SELECT tabTimeDetails.Det_Date, tabTimeDetails.DetailID,
tabTimeDetails.TimeStart, tabTimeDetails.TimeStop, " & _
"tabTimesheet.Employee_Number FROM tabEmployees INNER JOIN
(tabTimesheet INNER JOIN " & _
"tabTimeDetails ON tabTimesheet.ID =
tabTimeDetails.TimesheetID) ON " & _
"tabEmployees.Employee_Number = tabTimesheet.Employee_Number
WHERE " & _
"(((tabTimeDetails.Det_Date)= #" & stDate & "#) AND
((tabTimesheet.Employee_Number)= '" & _
stEmployee_Number & "' AND DetailID <> " & lDetailID & "))"
Set rsSet = dbs.OpenRecordset(stSQL, dbOpenForwardOnly)
With rsSet
While (Not rsSet.EOF And bOverLap = False)
If ((tStartTime >= !TimeStart) And (tStartTime < !TimeStop))
Then
' Check Start Time
bOverLap = True
MsgBox lDetailID & " Start Time overlaps with Shift " &
!DetailID, vbExclamation
Else
' Check Stop Time
If ((tStopTime > !TimeStart) And (tStopTime <=
!TimeStop)) Then
bOverLap = True
MsgBox lDetailID & " Stop Time overlaps with Shift "
& !DetailID, vbExclamation
End If
End If
rsSet.MoveNext
Wend
.Close
I have a client who enters employee Shifts. The 3 fields that mark a
shift as duplicate are if the TimeDate is the same, and the TimeStart and
TimeStop overlap. The code I'm currently using is also below, Seems easy,
but I've come across some problems. Best way is with some examples of the
problems. Assume all these are for the same date
CASE 1
Shift 1: 10:00 to 10:30
Shift 2: 09:00 to 11:00
Shift 2 won't come up as a duplicate, as the times are outside Shift 1.
CASE 2:
Shift 1: 22:00 to 08:00
Shift 2: 22:00 to 08:00
Here the problem is that Timestop is actually the next day.
I'm looking for an efficient way of checking, rather that just loads if
statements. Any ideas?
Thanks
Diarmuid
'***********************************************
stSQL = "SELECT tabTimeDetails.Det_Date, tabTimeDetails.DetailID,
tabTimeDetails.TimeStart, tabTimeDetails.TimeStop, " & _
"tabTimesheet.Employee_Number FROM tabEmployees INNER JOIN
(tabTimesheet INNER JOIN " & _
"tabTimeDetails ON tabTimesheet.ID =
tabTimeDetails.TimesheetID) ON " & _
"tabEmployees.Employee_Number = tabTimesheet.Employee_Number
WHERE " & _
"(((tabTimeDetails.Det_Date)= #" & stDate & "#) AND
((tabTimesheet.Employee_Number)= '" & _
stEmployee_Number & "' AND DetailID <> " & lDetailID & "))"
Set rsSet = dbs.OpenRecordset(stSQL, dbOpenForwardOnly)
With rsSet
While (Not rsSet.EOF And bOverLap = False)
If ((tStartTime >= !TimeStart) And (tStartTime < !TimeStop))
Then
' Check Start Time
bOverLap = True
MsgBox lDetailID & " Start Time overlaps with Shift " &
!DetailID, vbExclamation
Else
' Check Stop Time
If ((tStopTime > !TimeStart) And (tStopTime <=
!TimeStop)) Then
bOverLap = True
MsgBox lDetailID & " Stop Time overlaps with Shift "
& !DetailID, vbExclamation
End If
End If
rsSet.MoveNext
Wend
.Close