programmed parameter query in report

  • Thread starter Thread starter Wim
  • Start date Start date
W

Wim

Hi all,

I want to generate a report from within VBA. The report
gets its records from a parameter query
(called "Results"), where the only parameter (as filled in
in the "criteria" field of the query) is :

[Give the starting date : ]

the code :

Set rst = db.OpenRecordset("Results", dbOpenDynaset)
DoCmd.OpenReport strReportName, acViewPreview, , ,
acWindowNormal
DoCmd.Close acReport, strReportName, acSaveNo

The error message is : "too few parameters. Expected 1"

Apparently I should be able to get the starting date from
a parameter input screen, but how ?

Thanks for helping,

Wim
 
Wim said:
I want to generate a report from within VBA. The report
gets its records from a parameter query
(called "Results"), where the only parameter (as filled in
in the "criteria" field of the query) is :

[Give the starting date : ]

the code :

Set rst = db.OpenRecordset("Results", dbOpenDynaset)
DoCmd.OpenReport strReportName, acViewPreview, , ,
acWindowNormal
DoCmd.Close acReport, strReportName, acSaveNo

The error message is : "too few parameters. Expected 1"

Apparently I should be able to get the starting date from
a parameter input screen, but how ?

The error message is coming from the OpenRecordset (the VBA
environment does not have access to the expression service
that is used to resolve parameters). In this situation,
don't worry about it because there is no reason to be
mucking about with a recordset. Also, it would be a bad
idea to Close the report before the user has had a chance to
view it (users will close it when they're done looking at
it). All you need is OpenReport line, so get rid of the
other two lines.
 
Thank you, I'll give it a try !
-----Original Message-----
Wim said:
I want to generate a report from within VBA. The report
gets its records from a parameter query
(called "Results"), where the only parameter (as filled in
in the "criteria" field of the query) is :

[Give the starting date : ]

the code :

Set rst = db.OpenRecordset("Results", dbOpenDynaset)
DoCmd.OpenReport strReportName, acViewPreview, , ,
acWindowNormal
DoCmd.Close acReport, strReportName, acSaveNo

The error message is : "too few parameters. Expected 1"

Apparently I should be able to get the starting date from
a parameter input screen, but how ?

The error message is coming from the OpenRecordset (the VBA
environment does not have access to the expression service
that is used to resolve parameters). In this situation,
don't worry about it because there is no reason to be
mucking about with a recordset. Also, it would be a bad
idea to Close the report before the user has had a chance to
view it (users will close it when they're done looking at
it). All you need is OpenReport line, so get rid of the
other two lines.
 
Back
Top