How to refresh my Data Table!!!! (1 Viewer)

sbaud2003

Member
Local time
Today, 15:49
Joined
Apr 5, 2020
Messages
178
Hi Sir/Madam

I have a Room Reservation database, CHECK CONSTRAINT has been applied to the RoomOccupations table to prevent double booking of the same room by intersecting ranges:
However, I am facing a problem that every time I wants to book consecutive bookings , an error message of CHECK CONSTRAINT appears as applied by me only, although there is a vacant room. For doing the same I have quit the database and re-login into it.

I don't know way its happening
 

jdraw

Super Moderator
Staff member
Local time
Today, 06:19
Joined
Jan 23, 2006
Messages
15,379
I suggest you post a copy of the database with instructions to repeat your issue.

Sample room reservation
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:19
Joined
Feb 19, 2002
Messages
43,275
Whatever you are doing is locking the record when it shouldn't. If you don't want to post the whole db, you'll need to find the code that is dirtying the form. It is poor practice to write code that dirties the form. Your code should never populate fields or change anything until the user has typed at least one character into some control.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:19
Joined
May 21, 2018
Messages
8,529
However, I am facing a problem that every time I wants to book consecutive bookings , an error message of CHECK CONSTRAINT appears as applied by me only, although there is a vacant room.
That sounds to me that your logic at the edge is not correct. It is correct when one reservation fully overlaps, it is correct when there is a a gap, but the logic is wrong when one period adjoins another period. Remember dates have a time component and sometimes this is forgotten when applying logic. Depending on how a user inputs a date, a time component besides 0 (12:00 AM) may be added.

Need to check for all the following conditions (or you can check the negation)
Period B end Greater than or equal Period A Start and less that or equal period A End (Period B ends inside A period)
or
Period B Start Greater than or equal Period A start and Less than or equal period A End (Period B starts inside A period)
Period B Start <= Period A Start and Period B End >= Period A End (B spans the whole A period)
 

sbaud2003

Member
Local time
Today, 15:49
Joined
Apr 5, 2020
Messages
178
That sounds to me that your logic at the edge is not correct. It is correct when one reservation fully overlaps, it is correct when there is a a gap, but the logic is wrong when one period adjoins another period. Remember dates have a time component and sometimes this is forgotten when applying logic. Depending on how a user inputs a date, a time component besides 0 (12:00 AM) may be added.

Need to check for all the following conditions (or you can check the negation)
Period B end Greater than or equal Period A Start and less that or equal period A End (Period B ends inside A period)
or
Period B Start Greater than or equal Period A start and Less than or equal period A End (Period B starts inside A period)
Period B Start <= Period A Start and Period B End >= Period A End (B spans the whole A period)
thanks a lot ... got your point, checking the details
 

Users who are viewing this thread

Top Bottom