send sections to printer seperately

  • Thread starter Thread starter icccapital
  • Start date Start date
I

icccapital

I have a report that I would like to be able to send to the printer by
section. i.e. send pages 1-4 and then the next group header starts a new
page so send the next pages. I am trying to think of ways to do this, and
right now I have a textbox at the bottom that starts counting pages in this
manner (so page 1 is beginning of header, etc) If I could get this
information in vba maybe I could use it to print starting at this page to the
next. What do you think?

BTW- the reason for this is the ability to staple each group seperately.
 
I was also thinking that if I could collect these pages as the report is
being built, ie into an array, i could print them by page number later. But
i don't see an event that continually gets called throughout the build stage
of the report. Is there one?
 
One way of doing it - create a query that gets all possible values that are
used for the grouping - I'm assuming you're using Sorting and Grouping wihtin
the report, and the field you are grouping by is the one you're concerned
with. So get all unique values for that field in a query recordset, then in a
While loop, print the report and use a filter based on the current value from
the recordset. e.g. if you're grouping by date and the date field is called
myDAte, create a query that gets all dates that would be included in your
record source for the report. Then do something like

dim rst as adodb.recordset

set rst = new adodb.recordset
rst.open "qryGetDAtes", ...
while not rst.eof
docmd.openreport "report",,,"myDAte = " & rst!myDAte
wend
rst.close
set rst = nothing

This should print a seperate report for each value of myDate.
 
Thank you for the reply. That was one of my ideas, and I tried it. what
happened was it would work fine for the first 10 groups or so and then all of
the sudden the program would stop running. I tried to trap it with
breakpoints, but even then as I stepped through the code as soon as it
finished printing one of the groups, it would just stop with no message and
not stop at the breakpoint. It was really strange.

So i temporarily abandoned that idea, but am willing to go back to it if
someone has an idea for a solution for the above problem. Thanks agian.
 
AG, actually I had seen that code and I do have the page numbers themselves
working, but I can't seem to figure out what the last thing the report does
before being displayed, because it is there that i would want to send the
print job with all the pages I have collected.
 
Sorry, I don't understand. Do you want to print without displaying the
report? You can do that easily via code or a macro.
 
AG,

Thanks for trying to help. I was actually attempting to print the reports.
But I wanted to know at which pages a new group header would start and then
send those print jobs seperately (i.e. print pg 1-5 then print 6-8, etc).

Anyway, I figured out why my loop through a recordset and calling the
openreport with this info wasn't working. It turns out that if a report
query is null then the calling function with openreport in it will not be
returned to. The program just stops. So I just made sure the query wasn't
null and all is well.

Thanks again for the help
 
Back
Top