Print Mulitple Reports Related to Record

  • Thread starter Thread starter jburns
  • Start date Start date
J

jburns

Hi, I'd like to print 4 reports related to an individual
record. I thought I saw somewhere how to do this from one
command button but I can't find the info anywhere now.
Can someone point me in the right direction?

Regards
 
One easy way is to create a loop to repeat the OpenReport
command. You can hard code your four or you can prompt the
user for how many. I will give you the prompt part as well
and you can just take those lines out if you don't need
them. No error handling included...

Dim lngCopies as Long, lngCopied as Long

' Here is where you could also just specify 4
lngCopies = InputBox("How many copies would you like?")

Do Until lngCopied = lngCopies
DoCmd.OpenReport "YourReportName", acNormal
lngCopied = lngCopied + 1
Loop

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
Gary said:
One easy way is to create a loop to repeat the OpenReport
command. You can hard code your four or you can prompt the
user for how many. I will give you the prompt part as well
and you can just take those lines out if you don't need
them. No error handling included...

Dim lngCopies as Long, lngCopied as Long

' Here is where you could also just specify 4
lngCopies = InputBox("How many copies would you like?")

Do Until lngCopied = lngCopies
DoCmd.OpenReport "YourReportName", acNormal
lngCopied = lngCopied + 1
Loop


Gary, you have to be careful with that. If the report is
already open, issuing another OpenReport on the same report
will not create another instance. Depending on the timing,
it may do various things from just giving the report the
focus (if being previewed) to possibly changing its record
source or filter (if the report has code to do that kind of
stuff).

If the original question was about generating four different
reports, then just using an OpenReports for each report is
fine. But to print multiple copies of the same report with
the same data, the PrintOut method is the easiest approach.

If its the same report and PrintOut doesn't fit the
situation or if the data is different between the copies,
then a substantial amount of code is needed to create and
manage multiple instances of the report.
 
Marsh,

Thanks, you bring up some good points, although I was under
the impression that PrintOut was only useful for a datasheet
or form that was already active. Does this also work for a
report and does it have to be open in Preview first?

I should probably have included DoEvents and a Close within
the loop for caution, and on reading the original post
again, you may be correct that it would be 4 different
reports.

Thanks,

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
Gary said:
Thanks, you bring up some good points, although I was under
the impression that PrintOut was only useful for a datasheet
or form that was already active. Does this also work for a
report and does it have to be open in Preview first?

Yes and AFAIK Yes
I should probably have included DoEvents and a Close within
the loop for caution, and on reading the original post
again, you may be correct that it would be 4 different
reports.

I don't think DoEvents is guaranteed to deal with it. I've
never studied it in detail, but since reports do so much
I/O, they probably give control back to the form pretty
quickly (my guess is very soon after the Open event
processing).
 
Back
Top