input parameter

  • Thread starter Thread starter JIM.H.
  • Start date Start date
J

JIM.H.

Hello,
How can I provide an input parameter for my report. I need
to get a date and make query based on the date.
Thanks,
Jim.
 
Hi Jim

to get you started, create a query and in the CRITERIA line of the date
field (the one you want to use as the input parameter) type
[Enter Date]
now run the query and you will see that you are prompted to enter the date -
now build a report based on this (using the report wizard) and then when you
run the report you will be prompted for the date

then to make it nice and neat, create a form with an unbound text box (and
name the text box something like RPTDATE) then, go back to the query and
change the criteria to
Forms![whatever you called the form with the date on it].RPTDATE (use the
expression builder to get the exact syntax)

- put a button on this form - use the command button wizard, choose Report
Operations - Preview a Report (or whatever the exact wording is) - select
the appropriate report

now when you open the form, enter the date, press the button - the report
will display the information you want

you can then add code to check that a valid date has been entered / to close
the date form etc

Hope this helps - let us know if you'ld like help with the "clean up code"
Cheers
JulieD
 
Jim,

Are you printing your report via clicking a button on a form somewhere?
Just put an unbound textbox on this form, where you can enter the date
you need. And then, in the criteria of the date field, in the query
that the report is based on, refer to this textbox using syntax such as
[Forms]![NameOfYourForm]![NameOf Textbox]
 
Thanks Steve and Julie,
If user does not provide a date it should bring all
records. How can I do that? I tried to use IFF there but
could not succeed.
Thanks,
Jim.
-----Original Message-----
Jim,

Are you printing your report via clicking a button on a form somewhere?
Just put an unbound textbox on this form, where you can enter the date
you need. And then, in the criteria of the date field, in the query
that the report is based on, refer to this textbox using syntax such as
[Forms]![NameOfYourForm]![NameOf Textbox]

--
Steve Schapel, Microsoft Access MVP


JIM.H. said:
Hello,
How can I provide an input parameter for my report. I need
to get a date and make query based on the date.
Thanks,
Jim.
.
 
Jim,

Like this...
[Forms]![NameOfYourForm]![NameOf Textbox] Or
[Forms]![NameOfYourForm]![NameOf Textbox] Is Null
 
Thanks Steve,
That is working perfectly. Now on the same table and
query, I have this in a different date field

Between [Forms]![ myForm]![StartDate] And [Forms]![
myForm]![EndDate]

I need to get his working if one of the date is not
entered through form.
So I have myField, StartDate, EndDate and if there are
something entered in any of them they should act as a
constraint.
Thanks
Jim.
-----Original Message-----
Jim,

Like this...
[Forms]![NameOfYourForm]![NameOf Textbox] Or
[Forms]![NameOfYourForm]![NameOf Textbox] Is Null

--
Steve Schapel, Microsoft Access MVP


JIM.H. said:
Thanks Steve and Julie,
If user does not provide a date it should bring all
records. How can I do that? I tried to use IFF there but
could not succeed.
Thanks,
Jim.
.
 
Jim,

Between [Forms]![myForm]![StartDate] And [Forms]![myForm]![EndDate] Or
([Forms]![myForm]![StartDate] Is Null And [Forms]![myForm]![EndDate] Is
Null) will take care of the situation where neither of the date criteria
textboxes have a value entered in them. The rest of it depends on what
you want the behaviour to be in the case of an entry in only one of the
date criteria and not the other. Whatever the case, note that you can
enter expressions like this into the criteria of the query design grid,
but after you save the query and then open again in design view, you
will see that Access has shuffled the syntax around to suit its own
purposes... don't worry about this.
 
Back
Top