date parameters

J

JohnB

can someone please tell me if it is possible to use two
unbound boxes in the main switchboard that I can use for
date parameters to pull up reports? For example I need to
pull up all the icu procedures between 1-Apr-03 to 31-Mar-
04. I really don't want to have to remember at the end of
the year to go and change all the date values in every
query. Is it possible and how do I go about doing it? I
am using Access 97 and am relatively a new user.

Thanks for your help.
 
L

Larry Linson

Certainly... if it is your own switchboard form... even if it's not you can
create a form just to collect the dates from the user.

Don't use a parameter query. Base your report on the query you want to use
but with no WHERE clause.

For dates in TextBoxes txtFrom and txtTo, in the code behind the
CommandButton:

Dim strWhereCond as String
strWhereCond = "BETWEEN #" & Me!txtFrom & "# AND #" & Me!txtTo & "#"
DoCmd.OpenReport "yourreportsname",,,strWhereCond

It would be a good idea, though to check to make certain a date _has_ been
entered into both those Text Boxes, lest the user get an ungracious error
message of some kind when one is omitted.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top