Using MS Access/Parameter query form - Date range
I know how to create a parameter query in access but I know you have a much neater solution with an unbound form containing two text boxes and a command button and using VBA.
Unfortunately, I cannot recall how to go about it and I have mislaid my documentation that you provided previously. I know that if you enter only the start date and click, then you get all records from that date in the report; if you enter only the end date and click, then you get all records up till that date ; and if you simply click the button you get all records.
Could you kindly refresh my memory in this regard?
Any value in an Open form can be referenced using the syntax:
The way I generally do it is with 2 unbound textboxes on an unbound form. The Default values for these these textboxes are set as:
DMin("[datefield]","tablename") for txtStart and
DMax("[datefield]","tablename") for txtEnd
the criteria int he query is set to:
BETWEEN forms!formname!txtStart AND Forms!formname!txtEnd
So if the user doesn't change anything they get all the records. If they only change the start date then they get records from that date. If te only change the end date they get records up to that date. If they change both dates they get records between the entered dates.
Hope this helps,
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA