Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing A Report Parameter 1

Status
Not open for further replies.

DougAtAvalon

Programmer
Jan 29, 2001
99
US
Can I pass a report/query parameter that the user would otherwise be prompted for.?

-Doug
 
yes, you can.

Let's say you kick off a report from a button on a form.

You would have code (this is psuedocode) like this...

Set a querydef object equal to your query

Set the parameter of the querydef object equal to the value.

Open the report based on the query

Kathryn


 
I know how to do it if your saying...

....write the code for the sql and assign it to the query before I open the report?

is this what your saying?

-Doug

 
No, not exactly, although you could do that.

What I am suggesting is to create the query first, using the regular query design. Put a parameter in the criteria of the field. Save the query.

Let's say that the query was names qryTest, the parameter was "ProductNumber", and the report was rptTest and rptTest was based on qryTest. your code would be:


dim qdf as querydef

set qdf = currentdb.querydefs("qryTest")

qdf.parameters("ProductNumber") = 123

docmd.openreport "rptTest"


That might not be exact, but I think that it is pretty close. Is that what you want to do. Kathryn


 
yes that is what I want to do:

dim qdf as querydef
set qdf = currentdb.querydefs("qryTest")
qdf.parameters("ProductNumber") = 123
docmd.openreport "rptTest"


you mean here it won't prompt the user if in design view it it ProductNumber: [Please enter the Product Number]
-Doug
 
The parameter is the actual prompt you use.

dim qdf as querydef
set qdf = currentdb.querydefs("qryTest")
qdf.parameters("Please enter the Product Number") = 123
docmd.openreport "rptTest"


Kathryn


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top