Printing Multiple Reports

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I am trying to print a report based on a query. The query
contains invoice information for the month. I want to
create some code that will read each record into the
report and print. If there are thirty records in the
query I need to loop through the records and print each
report out with the appropriate information. Does anyone
know how I can accomplish this?

Thanks
Jeff
 
Jeff said:
I am trying to print a report based on a query. The query
contains invoice information for the month. I want to
create some code that will read each record into the
report and print. If there are thirty records in the
query I need to loop through the records and print each
report out with the appropriate information. Does anyone
know how I can accomplish this?


I don't see where using code would have anything to do with
it. Can't you you just use Sorting and Grouping (View menu)
to create a header/footer section for each invoice?
 
I wish it were that simple. The report consists of
formulas. I have played around with the page setup as you
suggested however it is still not formated correctly. I
have 30 invoices and I have now manipulated the report to
show all invoices on a separate sheet of paper but the
detail section that shows what was bought is inaccurate.
Currently 1 invoice is printed and through code a filter
on the orderID is made to only get information for that
order. This is why I was asking about doing this through
code. The fomulas do not calculate the way that you
suggested. I will look into this when I get the detail
section fixed.

Thanks
Jeff
 
Jeff said:
I wish it were that simple. The report consists of
formulas. I have played around with the page setup as you
suggested however it is still not formated correctly. I
have 30 invoices and I have now manipulated the report to
show all invoices on a separate sheet of paper but the
detail section that shows what was bought is inaccurate.
Currently 1 invoice is printed and through code a filter
on the orderID is made to only get information for that
order. This is why I was asking about doing this through
code. The fomulas do not calculate the way that you
suggested. I will look into this when I get the detail
section fixed.

OK, I see. But firing off multiple instances of the same
report object is complicated (even when it works).

It would probably be much easier to get the report to put
each invoice on a separate page correctly than to do what
you asked, but as long as you're not going to try to preview
the invoices, you could try:

Set rs = db.OpenRecordset( . . .
Do Until rs.EOF
DoEvents
DoCmd.OpenReport "invoice", , , "OrderID=" & rs!OrderID
Loop
rs.Close : Set rs = Nothing
Set db = Nothing

Like I said, that might not work so if it gives you trouble,
just give it up and let's work on the other problems.
 
In theory would seem to work but didn't. It only prints
the first record of the recordset. I think it will work
but I don't know how to move through the recordset. Any
other suggestions.

Jeff

-----Original Message-----
Jeff said:
I wish it were that simple. The report consists of
formulas. I have played around with the page setup as you
suggested however it is still not formated correctly. I
have 30 invoices and I have now manipulated the report to
show all invoices on a separate sheet of paper but the
detail section that shows what was bought is inaccurate.
Currently 1 invoice is printed and through code a filter
on the orderID is made to only get information for that
order. This is why I was asking about doing this through
code. The fomulas do not calculate the way that you
suggested. I will look into this when I get the detail
section fixed.

OK, I see. But firing off multiple instances of the same
report object is complicated (even when it works).

It would probably be much easier to get the report to put
each invoice on a separate page correctly than to do what
you asked, but as long as you're not going to try to preview
the invoices, you could try:

Set rs = db.OpenRecordset( . . .
Do Until rs.EOF
DoEvents
DoCmd.OpenReport "invoice", , , "OrderID=" & rs! OrderID
Loop
rs.Close : Set rs = Nothing
Set db = Nothing

Like I said, that might not work so if it gives you trouble,
just give it up and let's work on the other problems.
--
Marsh
MVP [MS Access]



.
 
After further testing I have concluded that the docmd
openreport kills the loop execution. Result is only one
invoice prints.
-----Original Message-----
Jeff said:
I wish it were that simple. The report consists of
formulas. I have played around with the page setup as you
suggested however it is still not formated correctly. I
have 30 invoices and I have now manipulated the report to
show all invoices on a separate sheet of paper but the
detail section that shows what was bought is inaccurate.
Currently 1 invoice is printed and through code a filter
on the orderID is made to only get information for that
order. This is why I was asking about doing this through
code. The fomulas do not calculate the way that you
suggested. I will look into this when I get the detail
section fixed.

OK, I see. But firing off multiple instances of the same
report object is complicated (even when it works).

It would probably be much easier to get the report to put
each invoice on a separate page correctly than to do what
you asked, but as long as you're not going to try to preview
the invoices, you could try:

Set rs = db.OpenRecordset( . . .
Do Until rs.EOF
DoEvents
DoCmd.OpenReport "invoice", , , "OrderID=" & rs! OrderID
Loop
rs.Close : Set rs = Nothing
Set db = Nothing

Like I said, that might not work so if it gives you trouble,
just give it up and let's work on the other problems.
--
Marsh
MVP [MS Access]



.
 
Jeff said:
After further testing I have concluded that the docmd
openreport kills the loop execution. Result is only one
invoice prints.

That's not the problem.

If you're not looping through the recordset using the kind
of code I posted, then, of course, you'll only print one
record. If you are looping through the recordset, then you
ran into the issues I was talking about before. The first
OpenReport is still running when the rest of the OpenReports
are executed, and since this approach can not start multiple
copies, the others have no effect.

Please, let's fix the problems in a normal report and forget
about trying to deal with these race conditions.
--
Marsh
MVP [MS Access]


-----Original Message-----
Jeff said:
I wish it were that simple. The report consists of
formulas. I have played around with the page setup as you
suggested however it is still not formated correctly. I
have 30 invoices and I have now manipulated the report to
show all invoices on a separate sheet of paper but the
detail section that shows what was bought is inaccurate.
Currently 1 invoice is printed and through code a filter
on the orderID is made to only get information for that
order. This is why I was asking about doing this through
code. The fomulas do not calculate the way that you
suggested. I will look into this when I get the detail
section fixed.

OK, I see. But firing off multiple instances of the same
report object is complicated (even when it works).

It would probably be much easier to get the report to put
each invoice on a separate page correctly than to do what
you asked, but as long as you're not going to try to preview
the invoices, you could try:

Set rs = db.OpenRecordset( . . .
Do Until rs.EOF
DoEvents
DoCmd.OpenReport "invoice", , , "OrderID=" & rs! OrderID
Loop
rs.Close : Set rs = Nothing
Set db = Nothing

Like I said, that might not work so if it gives you trouble,
just give it up and let's work on the other problems.
--
Marsh
MVP [MS Access]


-----Original Message-----
Jeff wrote:
I am trying to print a report based on a query. The
query
contains invoice information for the month. I want to
create some code that will read each record into the
report and print. If there are thirty records in the
query I need to loop through the records and print each
report out with the appropriate information. Does
anyone
know how I can accomplish this?


Marshall Barton wrote:
I don't see where using code would have anything to do
with
it. Can't you you just use Sorting and Grouping (View
menu)
to create a header/footer section for each invoice?

.
 
I was stepping through the code so this should have given
time to print and then loop but it did not.

I will continue to reformat the report or try anyway.

Thanks
Jeff

-----Original Message-----
Jeff said:
After further testing I have concluded that the docmd
openreport kills the loop execution. Result is only one
invoice prints.

That's not the problem.

If you're not looping through the recordset using the kind
of code I posted, then, of course, you'll only print one
record. If you are looping through the recordset, then you
ran into the issues I was talking about before. The first
OpenReport is still running when the rest of the OpenReports
are executed, and since this approach can not start multiple
copies, the others have no effect.

Please, let's fix the problems in a normal report and forget
about trying to deal with these race conditions.
--
Marsh
MVP [MS Access]


-----Original Message-----
Jeff wrote:

I wish it were that simple. The report consists of
formulas. I have played around with the page setup as you
suggested however it is still not formated correctly. I
have 30 invoices and I have now manipulated the report to
show all invoices on a separate sheet of paper but the
detail section that shows what was bought is inaccurate.
Currently 1 invoice is printed and through code a filter
on the orderID is made to only get information for that
order. This is why I was asking about doing this through
code. The fomulas do not calculate the way that you
suggested. I will look into this when I get the detail
section fixed.

OK, I see. But firing off multiple instances of the same
report object is complicated (even when it works).

It would probably be much easier to get the report to put
each invoice on a separate page correctly than to do what
you asked, but as long as you're not going to try to preview
the invoices, you could try:

Set rs = db.OpenRecordset( . . .
Do Until rs.EOF
DoEvents
DoCmd.OpenReport "invoice", , , "OrderID=" & rs! OrderID
Loop
rs.Close : Set rs = Nothing
Set db = Nothing

Like I said, that might not work so if it gives you trouble,
just give it up and let's work on the other problems.
--
Marsh
MVP [MS Access]



-----Original Message-----
Jeff wrote:
I am trying to print a report based on a query. The
query
contains invoice information for the month. I want to
create some code that will read each record into the
report and print. If there are thirty records in the
query I need to loop through the records and print each
report out with the appropriate information. Does
anyone
know how I can accomplish this?


Marshall Barton wrote:
I don't see where using code would have anything to do
with
it. Can't you you just use Sorting and Grouping (View
menu)
to create a header/footer section for each invoice?

.

.
 
Jeff said:
I was stepping through the code so this should have given
time to print and then loop but it did not.

I will continue to reformat the report or try anyway.


If you want help with that, just holler ;-)
 
Back
Top