Results 1 to 5 of 5
  1. #1
    rajnag is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    2

    Simple query problem

    Hi everyone,



    This is a pretty straightforward problem but I can't seem to wrap my head around it. I'm pretty much a noob when it comes to Access so bear with me!
    I've got a simple database for a hotel room booking system with 3 tables as below:

    tblCustomer:
    CustomerID
    Forename
    Surname
    etc

    tblBooking:
    BookingID
    CustomerID
    RoomID
    BookingDate

    tblRooms:
    RoomID
    RoomNumber
    RoomType
    RoomCost

    The requirements of the system are pretty basic, each customer who makes a booking only stays for one night at a time in one room.

    What I'm trying to do is set up a way for the user to specify a date, and then have the system return which rooms are free (unbooked) on that date.

    I've got some idea that I need to use a query to do this. I understand how to get it to show me rooms which are booked on that day, just not rooms which are NOT booked on that day.
    I've been banging my head against a wall on this one, can someone please point me in the right direction?

    Thanks!

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    its not as simple as it sounds. if your Booking tbl has a record of every single date then your basic date query finds those rooms which are booked.

    Call this query1.

    Make another new query, use the 'Query Wizard' and look for the 'Find Unmatched Query Wizard'....follow the wizard carefully and compare between query1 and Rooms table.

  3. #3
    Join Date
    Aug 2010
    Location
    SoCal
    Posts
    1

    Great...

    Thanks for posting this, as I am a little new to access, I have just joined because I start a new class at school in 2 weeks that involves this same exact stuff. I purchased 2 books, Access 2007 VBA and Access 2007 Programming as the teacher instructed to do for help with examples.

    If these books don't help me, than I hope I can get help here at this forum, since it is obvious that there are some experienced people that have enough knowledge to help solve problems with simple navigation, and the like in Access.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Create a query "RoomBooked" as:

    SELECT tblBooking.RoomID FROM tblBooking GROUP BY tblBooking.RoomID, tblBooking.BookingDate HAVING (((tblBooking.BookingDate)=[WhichDate]));

    Create another query "RoomNotBooked" as:

    SELECT tblRooms.* FROM tblRooms LEFT JOIN RoomBooked ON tblRooms.RoomID = RoomBooked.RoomID WHERE (((RoomBooked.RoomID) Is Null));

    Run query "RoomNotBooked", it requires to type in a date, and then vacant rooms information will show.

  5. #5
    rajnag is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    2

    Smile

    Quote Originally Posted by weekend00 View Post
    Create a query "RoomBooked" as:

    SELECT tblBooking.RoomID FROM tblBooking GROUP BY tblBooking.RoomID, tblBooking.BookingDate HAVING (((tblBooking.BookingDate)=[WhichDate]));

    Create another query "RoomNotBooked" as:

    SELECT tblRooms.* FROM tblRooms LEFT JOIN RoomBooked ON tblRooms.RoomID = RoomBooked.RoomID WHERE (((RoomBooked.RoomID) Is Null));

    Run query "RoomNotBooked", it requires to type in a date, and then vacant rooms information will show.
    Thank you so much, it works beautifully!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. simple form problem
    By kcsun in forum Forms
    Replies: 0
    Last Post: 08-12-2010, 12:28 AM
  2. Simple query Question, please Help
    By iamraja5 in forum Forms
    Replies: 1
    Last Post: 03-16-2010, 05:04 AM
  3. simple query
    By taylorosso in forum Queries
    Replies: 1
    Last Post: 10-06-2009, 04:26 AM
  4. Need Help with a very simple query
    By bikerguy06 in forum Queries
    Replies: 3
    Last Post: 06-08-2009, 08:43 PM
  5. Help with a simple query
    By JohnnyO in forum Queries
    Replies: 1
    Last Post: 02-11-2009, 09:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums