Passing a Query-based Report a Query Parameter

  • Thread starter Epilepsie Montreal Metropolitain
  • Start date
E

Epilepsie Montreal Metropolitain

Hello:

I posted this message on Monday, July 14 and it seems to
have got lost--so I'll try again!

I have a query-based report that requires an input parameter
(a receipt number) before displaying the receipt data prior to
printing. Now, the report requires no code, but since it must
take the parameter from the user (via a Form I presume...),
will the report have to be coded and will the query be coded
too? Could you give me any suggestions about how best to
go about this--code examples, outline of program, etc?

Thanks for your help,
I hope this message gets through this time...

Dave H
 
C

Casey

If the parameter you are using in your query of your
receipt number field criteria is like this
[please enter a receipt number]
that is all that you need, because when the person goes to
open the report, the words "please enter a receipt number"
will automatically ask for the receipt number prior to the
report opening. So all you have to do is create a form,
place a button on it, in the onclick property of the
button (right click on the button in design view and
select Properties), create a macro which will perform the
openreport action, and for the criteria for that action
iterate the name of the report you are interested in.

That is all that you need to do.

I hope that I helped.

Casey
 
N

Newbie

True you can do as Casey says but I found that by using the [parameter] it
wasn't easy to control when a user pressed cancel on the parameter box.
By entereing a parameter via the form it is easier to perform
errorhandling - specifically for error 2501

HTH

Ali
Casey said:
If the parameter you are using in your query of your
receipt number field criteria is like this
[please enter a receipt number]
that is all that you need, because when the person goes to
open the report, the words "please enter a receipt number"
will automatically ask for the receipt number prior to the
report opening. So all you have to do is create a form,
place a button on it, in the onclick property of the
button (right click on the button in design view and
select Properties), create a macro which will perform the
openreport action, and for the criteria for that action
iterate the name of the report you are interested in.

That is all that you need to do.

I hope that I helped.

Casey
-----Original Message-----
Hello:

I posted this message on Monday, July 14 and it seems to
have got lost--so I'll try again!

I have a query-based report that requires an input parameter
(a receipt number) before displaying the receipt data prior to
printing. Now, the report requires no code, but since it must
take the parameter from the user (via a Form I presume...),
will the report have to be coded and will the query be coded
too? Could you give me any suggestions about how best to
go about this--code examples, outline of program, etc?

Thanks for your help,
I hope this message gets through this time...

Dave H


.
 
S

Steve Schapel

Dave,

You do not need to make any changes to your report. All you need to
do is enter something in the criteria of the query. If you want the
criteria to be entered via a form, put an unbound textbox on the form,
and then refer to this textbox in the query criteria using syntax such
as [Forms]![NameOfForm]![NameOfTextbox]
If you want the user to be prompted for the criteria at the time the
report is printed, put your desired wording of the parameter prompt
within []s in the query criteria, such as
[Enter receipt number required...]

- Steve Schapel, Microsoft Access MVP
 
A

Andy Cole

Hi Dave

Your post *did* appear as I responded together with PC Datasheet. However I
think there were problems with the NG postings on Monday/Tuesday - I didn't
see you post till Tuesday. You'll find all responses on a Google Groups
Search though.

Andy
 

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