Reservation Query SQL

Posted on 2006-04-11
Last Modified: 2011-09-20
I have recently been tring to model a hotel reservations database I found the following query online it says it is supposed to query my reservations table for available rooms by date:

FROM tblReservations
WHERE Room_Id NOT in (select Room_Id from tblReservations where     RequestedStartDate <= EndBookingDate and RequestedEndDate >= StartBookingDate );

Question # 1
I am new to sql parameter queries and  what I don't undestand is why I have to input a start bookingdate and an endbookingdate. Shouldn't the user just add the input the requested dates the guest would like to find the rooms available within the time frame

Question # 2
I would like to know if i can insert use this query in a form where the user inserts the request dates via a combo boxes and calendar control, clicks a control button and gets the results in another form.Is this possible using vbcode as well?

Question by:wkellya
    1 Comment
    LVL 74

    Accepted Solution


    Assume the following Data in the tblReservations.

    ReservationID,Room_ID,StartBookingDate,End Booking Date

    The query works as expected and asks for a Start and End dates.
    (Isn't that what you wanted?)

    One note though, if a room is not in the Reservations table, it won't ever be displayed as being free.

    For example: let's say you have another room, 400. Notice that it is not in tblReservations, because it has NO reservations, so it will not be listed in the query as being free.

    So in this case you also need a a table for the Rooms (tblRooms)
    Room_ID, RoomCategory, RoomName...ect

    This new table must also be included in the query to show rooms that may not have any reservations at all. (Thus they are "available")

    Now as far as your second question...
    Yes, you can do this with VBA.

    Is this question really only worth 55 points to you?

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now