Hi,
I have a query that is wrecking my head, it is the format of my query that is my problem. I have a form that a users has an option to select a trainee name and filter the data, now I want to add a start and end date, sounds easy but no matter what I try, my query is showing all the results or none of the results. I would like the option that if no dates were selected, all records would show. Below is my code. I have tried all combinations of AND or OR but have had no luck. Should I be going about this in a different way?
Thanks in advance,
Poco
I have a query that is wrecking my head, it is the format of my query that is my problem. I have a form that a users has an option to select a trainee name and filter the data, now I want to add a start and end date, sounds easy but no matter what I try, my query is showing all the results or none of the results. I would like the option that if no dates were selected, all records would show. Below is my code. I have tried all combinations of AND or OR but have had no luck. Should I be going about this in a different way?
Thanks in advance,
Poco
Code:
SELECT tblTrainingRecords.Trainee.Value, tblTrainingRecords.Trainer, tblTrainingRecords.TrainingDescription, tblTrainingRecords.Comments, tblTrainingRecords.AreaOfTraining, tblTrainingRecords.TrainingDate, tblTrainingRecords.ID, tblTrainingRecords.TraineeHours, tblTrainee.Trainee
FROM tblTrainee INNER JOIN tblTrainingRecords ON tblTrainee.ID = tblTrainingRecords.Trainee.Value
WHERE (((tblTrainingRecords.Trainee.Value)=Forms!frmTrainee!cboTrainee) OR ((tblTrainingRecords.TrainingDate)>=Forms!frmTrainee!cboStartDate And (tblTrainingRecords.TrainingDate)<=Forms!frmTrainee!cboEndDate)) Or (((Forms!frmTrainee!cboTrainee) Is Null));