Print a series of reports based on a single date and a series of numbers

  • Thread starter Bill R via AccessMonster.com
  • Start date
B

Bill R via AccessMonster.com

OK. I'll try to get some help with this by breaking it down to its parts
(I've gotten no response to my other posts on the subject). The most
difficult part is trying to print a series of reports, based on the same
report object, using a static date criteria, and a changing number. So the
report header would look like:

Date: 9/25/2005 IPT: 10

and the detail of the report would reflect these 2 criteria. Then the report
would print and go on to the next IPT:

Date: 9/25/2005 IPT:15

and print it and so on, ...

My first problem is in code behind a form cmd button that I'm trying to use
to put together the SQL for the report's record source. When I try to set the
report variable (set rpt = Reports!rptDailyIPTMtg) I get runtime error 2451:
"The report name 'rptDailyIPTMtg' you entered is misspelled or refers to a
report that isn't open or doesn't exist". It is neither misspelled nor non-
existent. As far as "open" is concerned, that's a little confusing, isn't it?
The upshot is I probably won't be able to use the report object to change
recordsource in code in the form.

I can't figure out a way to cycle through the IPTs and print individual
reports for them based on the same date. I can't imagine how I could use
field references to the popup form I'm trying to use to run the reports. Is
there any way short of creating 20 different reports to accommodate all 20
IPTs?
 
L

Larry Linson

My first problem is in code behind a form
cmd button that I'm trying to use to put
together the SQL for the report's record
source. When I try to set the report variable
(set rpt = Reports!rptDailyIPTMtg) I get
runtime error 2451: "The report name
'rptDailyIPTMtg' you entered is misspelled
or refers to a report that isn't open or
doesn't exist". It is neither misspelled nor
non-existent. As far as "open" is concerned,
that's a little confusing, isn't it?

What's confusing about it? If the report is not visible on the screen,
either in design view or report view, then it is not Open. Only Open Reports
are in the Reports collection; otherwise, they are a type of document in a
container, and you can, with a little extra effort, open them in design view
to manipulate them but now (see below) there's an easier way.

The simple approach, prior to Access 2002, was to put code in the Report's
Open event to pick up the required information from an Open Form or a Public
Variable, build the SQL, and set the RecordSource.

With Access 2002, Reports gained the very useful OpenArgs property that
Forms have had at least since Access 2.0, and there is a corresponding
OpenArgs argument on DoCmd.OpenReport, which is likely what you use to Open
the Report.

Larry Linson
Microsoft Access MVP
 

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