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:
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:
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.
Help me people please before go totally mad :banghead::banghead:
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.
Help me people please before go totally mad :banghead::banghead:
Last edited: