pass parameter to report

  • Thread starter Thread starter -00Eric Clapton
  • Start date Start date
0

-00Eric Clapton

I want to write a button which will trigger a specific report required a
parameter. How can I pass a parameter to report using the access code?
 
I want to write a button which will trigger a specific report required a
parameter. How can I pass a parameter to report using the access code?

Base the Report on a Query using the parameter as a criterion.


John W. Vinson[MVP]
 
OK. In coding, what is the syntax to pass the parameter to the query and
how to run the report with passed parameter? Thanks.
 
Can anyone please help?


-00Eric Clapton said:
OK. In coding, what is the syntax to pass the parameter to the query and
how to run the report with passed parameter? Thanks.
 
OK. In coding, what is the syntax to pass the parameter to the query and
how to run the report with passed parameter? Thanks.

What's the context, Eric? Where is the parameter coming from?

One thing you could do, if the parameter is available within VBA but
not (readily) on a Form or other source, is actually construct the
Report's SQL string in code and set its Recordsource property to the
string.

Or, use the WhereCondition parameter of OpenReport:

Dim strSQL As String
strSQL = "[fieldname] = " & TheParameterValue
DoCmd.OpenReport "rptMyReport", WhereCondition := strSQL

John W. Vinson[MVP]
 
I put a parameter in select query and create a report which recordsource is
this query. Also write in code as the following suggested, but when I run
the following code. It keeps asking me the parameter value in the query even
after I set the theparametervalue = constant. Please help. THanks.


John Vinson said:
OK. In coding, what is the syntax to pass the parameter to the query and
how to run the report with passed parameter? Thanks.

What's the context, Eric? Where is the parameter coming from?

One thing you could do, if the parameter is available within VBA but
not (readily) on a Form or other source, is actually construct the
Report's SQL string in code and set its Recordsource property to the
string.

Or, use the WhereCondition parameter of OpenReport:

Dim strSQL As String
strSQL = "[fieldname] = " & TheParameterValue
DoCmd.OpenReport "rptMyReport", WhereCondition := strSQL

John W. Vinson[MVP]
 
Back
Top