Another newbie question. I have a table to track employees with many fields, including dates for various training and what site they work at. I have a form which is used to pass data to a query.
The fields on the form are "Site" (a combo box with 4 possible work sites), "Training Expires Start" and "Training Expires End" (date picker boxes), and then a button to run the query.
The query needs to find anyone whose training expires between the two chosen dates and the value in the Combo Box. That part is easy. However, I also want to return all entries for staff who work at the chosen "Site" but whose training date field is empty. Sadly I can't quite get the ANDs and ORs quite right. Here's the query:
SELECT StaffBasicInformation.FirstName, StaffBasicInformation.LastName, StaffBasicInformation.Site, StaffBasicInformation.EECTraining
FROM StaffBasicInformation
WHERE ((StaffBasicInformation.Site)=Forms!Expiry![1stAidEECSite])
AND (DateAdd("yyyy",3,StaffBasicInformation!EECTrainin g))>=Forms!Expiry![1stAidEECStartDate]
AND (DateAdd("yyyy",3,StaffBasicInformation!EECTrainin g))<=Forms!Expiry![1stAidEECEndDate]
OR ((StaffBasicInformation.Site)=Forms!Expiry![1stAidEECSite]) AND ((StaffBasicInformation.EECTraining) Is Null)
ORDER BY StaffBasicInformation.LastName;
It's only returning those entries whose EECTraining field is null. In pseudo-code, it should be something like:
Select all the Staff from ThisSite whose Training will expire between ThisDate and ThisDate as well as Staff from the ThisSite whose Training field is empty.
Thanks in advance!![]()