Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
I have an activity start time variable, lrtime equaling 0.7708333333 (7:00 PM)
I need to compare it to ensure that lrtime falls within the employee's shift. ie lrtime <= sel_crew1_end. The value for sel_crew1_end = 0 (midnight)
sel_crew1_end = 0 (12:00am)
lrtime = 0.7708333333 (7:00pm)
If my employee works 4:00pm to midnight, 7:00PM is before midnight so should not trigger this condition. But, the code isn't differentiating the difference betwee the midnight at the start of the day or midnight of the start of the next date, which is where the problem stems. Midnight of the same day would trigger the code because 7:00PM is not less than the start of the day, but it is less than the start of the next day (the employee's end time).
How can I overcome this issue?
I need to compare it to ensure that lrtime falls within the employee's shift. ie lrtime <= sel_crew1_end. The value for sel_crew1_end = 0 (midnight)
Rich (BB code):
sel_crew1_end = WorksheetFunction.VLookup(Me.cb_r1_crew & "1", ws_staff.Range("I5:M28"), 5, False)
lrtime = 0.7708333333 (7:00pm)
Rich (BB code):
If lrtime > sel_crew1_end Then 'crew 1 can't
MsgBox "This tournament service is scheduled for after this crew has left."
cb_r1_crew.Value = ""
Exit Sub
ElseIf lrtime < sel_crew1_start Then 'crew 1 can't
MsgBox "This tournament service is scheduled before this crew starts."
cb_r1_crew.Value = ""
Exit Sub
End If
If my employee works 4:00pm to midnight, 7:00PM is before midnight so should not trigger this condition. But, the code isn't differentiating the difference betwee the midnight at the start of the day or midnight of the start of the next date, which is where the problem stems. Midnight of the same day would trigger the code because 7:00PM is not less than the start of the day, but it is less than the start of the next day (the employee's end time).
How can I overcome this issue?
Last edited: