I am building an equipment check-out database. On the check out form I have the user fill in check out date/time and projected return date/time. On the check out form I am also displaying in a subform any reservations for the selected piece of equipment.
Upon pressing the Save button, I want to check the date range of the check out date/time - projected return date/time against the reserved date time/out - date/time in. If any of the time periods overlap, then I want to display an error message saying there is a reservation.
I am getting very confused looking at this and trying to figure it out. This is what I have so far (I've condensed field names so it's easier to read), but it doesn't work for every instance:
ElseIf (DateOut + TimeOut) >= ([[Reserve]![ResDateOut] + [Reserve]![ResTimeOut]) And (DateProjectedReturn + TimeProjectedReturn) <= ([frmReserve]![ResDateReturn] + [frmReserve]![ResTimeReturn]) Then
If MsgBox("There is a reservation for this time period. Continue check out anyway?", vbYesNo, "") = vbNo Then
Cancel = True
Else
GoTo SaveChangesLabel
End If
I'm thinking I need to do this in more than one step/string. If anyone has any hints, suggestions, I'd appreciate the help. Thank you! Laurie
Upon pressing the Save button, I want to check the date range of the check out date/time - projected return date/time against the reserved date time/out - date/time in. If any of the time periods overlap, then I want to display an error message saying there is a reservation.
I am getting very confused looking at this and trying to figure it out. This is what I have so far (I've condensed field names so it's easier to read), but it doesn't work for every instance:
ElseIf (DateOut + TimeOut) >= ([[Reserve]![ResDateOut] + [Reserve]![ResTimeOut]) And (DateProjectedReturn + TimeProjectedReturn) <= ([frmReserve]![ResDateReturn] + [frmReserve]![ResTimeReturn]) Then
If MsgBox("There is a reservation for this time period. Continue check out anyway?", vbYesNo, "") = vbNo Then
Cancel = True
Else
GoTo SaveChangesLabel
End If
I'm thinking I need to do this in more than one step/string. If anyone has any hints, suggestions, I'd appreciate the help. Thank you! Laurie