Reservation, booking system, query problem

system_error

New member
Local time
Yesterday, 18:37
Joined
Sep 1, 2013
Messages
2
[SOLVED] Reservation, booking system, query problem

Hello, I chose to make a car rental booking system as my semestral project in school. Im fresh IT-student. Ive never done before such projects and I decided to make it in MS Access because it looks pretty easy and I thought it would go smoothly but Im badly stuck and need somebody help plz :banghead:
Ok, so here is my problem:

I made typical for this kind of system tables: Cars and Bookings.

Also made a date picker form which takes:
Customer wanted start date: [Forms]![frmPickDateTerm]![StartDatePick]
and end of wanted booking date: [Forms]![frmPickDateTerm]![EndDatePick]

Table Bookings holds already booked CarsID and booking dates for this cars. The columns are: BookingID, StartBookDate, EndBookDate, CarID.

Table Cars holds data about all company cars and (for now) columns are: CarID, Model, Color


Tables: Booking and Cars are joined by CarID column.


After few days of struggle i made a query like this:
SELECT tblBookings.BookingID, tblBookings.StartBookDate, tblBookings.EndBookDate, tblCars.CarID, tblCars.Model

FROM tblBookings INNER JOIN tblCars ON tblBookings.CarID = tblCars.CarID

WHERE ((([Forms]![frmPickDateTerm]![StartDatePick])>([tblBookings]![StartBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])<([tblBookings]![EndBookDate])))
OR ((([Forms]![frmPickDateTerm]![StartDatePick])<([tblBookings]![StartBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])>([tblBookings]![EndBookDate])))
OR ((([Forms]![frmPickDateTerm]![StartDatePick])<([tblBookings]![EndBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])>([tblBookings]![EndBookDate])))
OR ((([Forms]![frmPickDateTerm]![StartDatePick])<([tblBookings]![StartBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])>([tblBookings]![StartBookDate])));

Above query works very good and give all existing bookings and related cars contained in a time period, chosen in date picker form. But I need the reverse thing. I need to reject the booked cars and showed the rest of the cars which are not booked for that time period.

So I googled little more and found that i need to make some kind of subquery containing with "NOT IN" formula.
The core of the problem is that I trying to make this subquery but Access wont work with it. I know i need to put one query into another so i make something like this:
SELECT tblBookings.BookingID, tblBookings.StartBookDate, tblBookings.EndBookDate, tblCars.Model
FROM tblBookings INNER JOIN tblCars ON tblBookings.CarID = tblCars.CarID
WHERE CarID NOT IN (

SELECT tblBookings.BookingID, tblBookings.StartBookDate, tblBookings.EndBookDate, tblCars.CarID, tblCars.Model
FROM tblBookings INNER JOIN tblCars ON tblBookings.CarID = tblCars.CarID
WHERE ((([Forms]![frmPickDateTerm]![StartDatePick])>([tblBookings]![StartBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])<([tblBookings]![EndBookDate]))) OR ((([Forms]![frmPickDateTerm]![StartDatePick])<([tblBookings]![StartBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])>([tblBookings]![EndBookDate]))) OR ((([Forms]![frmPickDateTerm]![StartDatePick])<([tblBookings]![EndBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])>([tblBookings]![EndBookDate]))) OR ((([Forms]![frmPickDateTerm]![StartDatePick])<([tblBookings]![StartBookDate])) AND (([Forms]![frmPickDateTerm]![EndDatePick])>([tblBookings]![StartBookDate])))

);

I made many, many variations of this but it always show message about wrong syntax, to complicated query or empty records.
Sorry for my bad english. Thats pity that can not post images, but I tried to explain this as best I can. :cool:

Help me people please before go totally mad :banghead::banghead::(
 
Last edited:
I cannot digest what you have done but have a look at this: http://www.baldyweb.com/OverLap.htm

Also, if you are looking for "the reverse thing" of what you've found in your first query, then just reverse the criteria:

Query 1: WHERE something
Query 2: WHERE NOT (something)

As to posting images, that would of course require reading the post at the top of this forum (an insurmountable obstacle for many) :D
 
Hello spikepl.
Thank You for your answer. You answered everything what I needed. Everything seems to work fine.


As to posting images, that would of course require reading the post at the top of this forum (an insurmountable obstacle for many) :D
I know, but it is hard to write 10 posts on specialist forum if you are noob and have a very little knowledge about this. :o You can go spam or to give incompetent(stupid) answers to others which would be very confusing.


Thanks one more time. I started to think that it is terribly complicated and I will not be able to do such system. But finally my problem is gone now I can go to sleep peacefully today. :)

(||)]
 

Users who are viewing this thread

Back
Top Bottom