I didn’t know how to express this problem that well in word form so have decided to use pictures to help me.
These are my tables and their relationships:

and here is the form I’m stuck on:

I’m trying to make the form so that when a start date and an end date are entered, a query in the caravan combobox’s row source is ran which shows all the caravans that are not booked during that period. My SQL skills right now are limited as I’m currently learning them for this project. This is the SQL query I have made so far:
SELECT tblCaravan.caravanID, tblCaravan.caravanType
FROM tblCaravan, tblCaravansWeeksBooked
WHERE (((tblCaravansWeeksBooked.startDate) Not Between [txtStartDate] And [txtEndDate])
AND ((tblCaravansWeeksBooked.endDate) Not Between [txtStartDate] And [txtEndDate]));
I have the caravan combobox requery itself when it has focus using a Macro in Access.
The problem is the SQL I have made is not working and I can’t see why. I made it work before by using two queries built with the wizard which were these:
SELECT tblCaravansWeeksBooked.startDate, tblCaravansWeeksBooked.endDate, tblCaravansWeeksBooked.caravanID
FROM tblCaravansWeeksBooked
WHERE (((tblCaravansWeeksBooked.startDate) Between [Start Date] And [End Date])
AND ((tblCaravansWeeksBooked.endDate) Between [Start Date] And [End Date]));
and
SELECT tblCaravan.caravanID, tblCaravan.caravanType
FROM tblCaravan LEFT JOIN qryWeeksBooked ON tblCaravan.caravanID = qryWeeksBooked.caravanID
WHERE (((qryWeeksBooked.caravanID) Is Null));
I hope someone here can help push me in the right direction, thanks for any help that is given.
Jake
Try this