Hello
I am new to Access World Forum
My access programming skills are intermediate
I have been trying to create a dlookup to check for overlapping bookings but over 3 hrs, i couldnt get it correct.
I get a message that is there is a overlapping booking even where there is none!( i have few testing records)
Here is the code.
Thanks in advance
God bless
I am new to Access World Forum
My access programming skills are intermediate
I have been trying to create a dlookup to check for overlapping bookings but over 3 hrs, i couldnt get it correct.
I get a message that is there is a overlapping booking even where there is none!( i have few testing records)
Here is the code.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim varNum As Variant '
varNum = Me.BookingDetailsID
If IsNull(varNum) Then varNum = 0
If Not IsNull(DLookup("BookingDetailsID", "tblBookingDetails", _
"(RoomID=" & _
Me.RoomID & ") And (CheckInDate<#" & Me.CheckOutDate & _
"#) And (CheckOutDate> #" & Me.CheckInDate & "#) And (BookingDetailsID<>" & _
varNum & ")")) Then
If MsgBox(" This entry creates an overlaping booking, do you want to proceed?", vbYesNo) = vbNo Then
Cancel = True
Exit Sub
End If
End If
End Sub
Thanks in advance
God bless