Rick,
Sure. I would probably write a function to test the values, or maybe do the
test in the forms BeforeUpdate event.
Private Sub Form_BeforeUpdate(Cancel as integer)
Dim dtRStart as date, dtREnd as date, _
dtOStart as Date, dtOEnd as date
dtRStart = me.RegWorkDate + me.RegWorkStart
dtREnd = me.regWorkDate + me.regWorkEnd
dtOStart = me.OTWorkDate + me.OTWorkStart
dtOEnd = me.OTWorkDate + me.OTWorkEnd
if dtOStart >= dtRStart AND dtOStart <= dtREnd Then
msgbox "OT Start must be after the regular work day ends!"
Cancel = True
elseif dtOEnd >= dtRStart AND dtOEnd <= dtREnd Then
msgbox "OT Start must be after the regular work day ends!"
Cancel = True
ENDIF
End Sub
You could throw some additional checks in there to make sure the regular
work end is greater than regular work start, and the same for the OT work end
and start.
HTH
Dale
--
Don''t forget to rate the post if it was helpful!
email address is invalid
Please reply to newsgroup only.
Rick_C said:
Karl,
Thank you for your response...
I have a follow-up...
I presume the query you gave me would be for a report. Is there a way that I
can put that query in the before or after update of the OTWorkEnd field so
that it let's me know before the record is saved?
Thanks in advance for your help...
Rick
:
This query will find overlap ---
SELECT Rick_C.EmpCode, Rick_C.RegWorkDate, Rick_C.RegWorkStart,
Rick_C.RegWorkEnd, Rick_C.OTWorkDate, Rick_C.OTWorkStart, Rick_C.OTWorkEnd
FROM Rick_C
WHERE (((Rick_C.OTWorkStart) Between [RegWorkStart] And [RegWorkEnd])) OR
(((Rick_C.OTWorkEnd) Between [RegWorkStart] And [RegWorkEnd]));
--
KARL DEWEY
Build a little - Test a little
:
I would appreciate some help coming up with this solution...
I am working with the following fields, and the Data Type is: Date/Time
RegWorkDate
RegWorkStart
RegWorkEnd
OTWorkDate
OTWorkStart
OTWorkEnd
I need to ensure that the OT data does not fall within the same date and
times as the RegWork data.
For example:
If someone works regular hours on 01/01/2008 from 8:00 a.m. to 5:00 p.m.,
then the OTWorkDate + the OTWorkStart AND OTWorkEnd cannot fall within those
times.
Thank you in advance for your assistance.
Rick