Hey Guys
I'm trying to set up a form to register employee vacations without overlapping days it worked fine however in the below case it doesn't detect an overlap
If I entered a vacation from Oct 2nd 2020 until Oct 4th 2020
Then I entered vacation from Oct 1st 2020 until Oct 5th 2020 for the same employee ID
I've done the code for both text box Start & end
I want it to detect this sort of overlap when I adjust the Leave End Date box
I'm trying to set up a form to register employee vacations without overlapping days it worked fine however in the below case it doesn't detect an overlap
If I entered a vacation from Oct 2nd 2020 until Oct 4th 2020
Then I entered vacation from Oct 1st 2020 until Oct 5th 2020 for the same employee ID
I've done the code for both text box Start & end
I want it to detect this sort of overlap when I adjust the Leave End Date box
Code:
Private Sub Leave_Start_Date_BeforeUpdate(Cancel As Integer)
Dim strDate As String
'We format the date string to include the '#' delimiters
strDate = Format(CDate(Me.Leave_Start_Date), "\#m/d/yyyy\#")
Cancel = DMin("(" & strDate & " Between [Leave Start Date] And [Leave End Date])", _
"[Trial]", _
"([Staff Number] =" & Me.Staff_Number & ")") Or _
DMin("(" & strDate & " Between [Leave Start Date] And [Leave End Date])", _
"[Trial]", _
"([Staff Number]=" & Me.Staff_Number & ")")
If Cancel Then _
Call MsgBox("This date overlaps with an existing date range", _
vbOKOnly)
End Sub
Comment