Calender in a query

  • Thread starter Thread starter Hank Hendrix
  • Start date Start date
H

Hank Hendrix

I have a report based on a query where the user must select a starting date
and ending date.
Is there a way to have these dates selected from a pop up calendar control
rather than typing them into the box?
Thanks
Hank
 
Hank,

Yes, but would require some code to synchronize the flow if you want it to
be a pop-up. Here's an alternatiove that doesn't require coding:

Make a new for, and call it, say, frmReportSelection
Add two Calendar activeX controls to it (while in form design view, go
Insert > ActiveX Control) and name them, say, cldFrom and cldTo.
Now leave the form aside for a minute, and go to the query that "feeds" the
report; where you currently have the
= [please enter starting date] And <=>= [please enter ending date]
criterion, type in this instead:
= Forms![frmReportSelection]![cldFrom] And <=
Forms![frmReportSelection]![cldTo]

Save the query. get back to the form, make your selection of dates and open
the report... bingo! Having gotten this far, it would be a shame to not take
an extra thirty seconds' step: add a command button to the form to open the
repor when clicked (the button wizzard supports it).

Of course, you can do the same on an existing form if you want, as long as
you make sure to modify the form name in the query criterion accordingly.

Also, you could use the Date & Time Picker control instead if the Calendar
control is too big, just make sure to adjuct the query criterion to:
= Int(Forms![frmReportSelection]![cldFrom]) And <=
Int(Forms![frmReportSelection]![cldTo])

to avoid "funny" results from the fact that the DTPicker control returns a
time part as well.

HTH,
Nikos

criteria, put in the
 
Back
Top