When editing a booking record I wish to validate the change by looking in the bookings table to check that confilct does not occur.
I have a record as follows:-
Location Start Date Start time End Time
Room 1 3/11/2011 08:00 AM 13:00 PM etc.
When I Edit Either Room or Date it appears to work OK but If I change the Time (either Start or end or Both) the code says it confilcts with another booking.
My Code is as follows:-
What is confusing me is that it works fine for changing a room or the date, but it conflicts when changing time (even though there is no other booking for the same date in this room?
Could anyone suggest where my code logic is incorrect?
I have a record as follows:-
Location Start Date Start time End Time
Room 1 3/11/2011 08:00 AM 13:00 PM etc.
When I Edit Either Room or Date it appears to work OK but If I change the Time (either Start or end or Both) the code says it confilcts with another booking.
My Code is as follows:-
Code:
'Setting the Variables assigned for the changed record dteDate = Me!BookStartDate strRoomNo = Me!BookLocation dteStartTime = Me!BookTime dteEndTime = Me!BookEndTime Valid = 0 ' The SQL String Variable below takes the info entered in the booking form to compare a table record. ' This is a cut and Paste from the Check Booking script within the Bookings form. WILL NOT WORK WHEN CHANGING TIME ONLY????? strSQL = "([BookStartDate] = #%D#) AND " & _ "([BookLocation] = '%R') AND " & _ "([BookTime] < #%E#) AND " & _ "([BookEndTime] > #%S#)" strSQL = Replace(strSQL, "%D", Format(dteDate, "m/d/yyyy")) ' Substitues form date to % variables strSQL = Replace(strSQL, "%R", strRoomNo) strSQL = Replace(strSQL, "%E", Format(dteEndTime, "H:m:s")) strSQL = Replace(strSQL, "%S", Format(dteStartTime, "H:m:s")) Valid = (DCount("*", "tblRoomsBooking", strSQL))
Could anyone suggest where my code logic is incorrect?
Comment