ready4data
Registered User.
- Local time
- Today, 05:27
- Joined
- Jun 4, 2002
- Messages
- 39
I have a table(tblLicense) with a field called License
It has rows with License1 License2 License3 ... License15
My other table is called tblReservations
It has fields License, FromDate, ToDate
It is populated from a web app so the License field can have any combination of the selected licenses from tblLicense separated by commas (eg: License2, License8, License13)
I was trying to write a new query to exclude selecting licenses that are already being used for a date range.
The query I place in the Criteria section:
Runs fine on its own and returns the correct data which is:
License2, License8, License13
If I paste that in the Criteria of the new query as: Not In(License2, License8, License13)
They are excluded which is correct.
When I use that in the criteria section of the new query as a subquery, The query runs but those are not excluded.
The full query is this:
Can anyone shed some light on this? What am I doing wrong.
Thanks,
Scott
It has rows with License1 License2 License3 ... License15
My other table is called tblReservations
It has fields License, FromDate, ToDate
It is populated from a web app so the License field can have any combination of the selected licenses from tblLicense separated by commas (eg: License2, License8, License13)
I was trying to write a new query to exclude selecting licenses that are already being used for a date range.
The query I place in the Criteria section:
Code:
SELECT tblReservations.License FROM tblReservations WHERE (((tblReservations.FromDate)=#2/12/2017#) AND ((tblReservations.ToDate)=#2/14/2017#));
License2, License8, License13
If I paste that in the Criteria of the new query as: Not In(License2, License8, License13)
They are excluded which is correct.
When I use that in the criteria section of the new query as a subquery, The query runs but those are not excluded.
Code:
Not Exists (SELECT tblReservations.License FROM tblReservations WHERE (((tblReservations.FromDate)=#2/12/2017#) AND ((tblReservations.ToDate)=#2/14/2017#));)
The full query is this:
Code:
SELECT tblLicense.License
FROM tblLicense
WHERE ((Not (tblLicense.License)=Exists (SELECT tblReservations.License FROM tblReservations WHERE (((tblReservations.FromDate)=#2/12/2017#) AND ((tblReservations.ToDate)=#2/14/2017#));)));
Can anyone shed some light on this? What am I doing wrong.
Thanks,
Scott