date criteria

  • Thread starter Thread starter John Baker
  • Start date Start date
J

John Baker

I have a query which I want to limit records by date. The table the query is
based on has a date field. Some of the records have null values entered for
the date.
I also have a form which has a Beginning Date text box and an End Date text
box. The form also has a Yes/No check box to specify that all records should
be selected.

I would like to have criteria in the date field of the query which allows
the selection of all records (including null date values) if the check box
is clicked, otherwise the records should be between the dates selected in
the Beginning Date text box and an End Date text box on the form.

I have tried many ways but just can't seem to get it.
Any help would be greatly appreciated.

John Baker
 
If you meant you want to select ALL Records when the CheckBox chkAllRecords
is checked or just the Records between the txtBeginDate and txtEndDate when
the CheckBox is not checked then the SQL String of the Query should be
something like:

SELECT *
FROM YourTable
WHERE (Forms!YourForm!chkAllRecords = True)
OR ([YourTable].[DateField] BETWEEN Forms!YourForm!txtBeginDate
AND
Forms!YourForm!txtEndDate)
 
Back
Top