Report - how to print each page to new document.

G

GA

Hello all,

I've been trying to get my head round how to do this and completely
failed.

I've got a report which I can print off without any problems to a pdf
but obviously I get a single pdf with several hundred pages (each
record prints to a new page) but what I want is to print mulitple
documents from one report and hopefully automatically name each one
using the one of the fields from the report.

Can someone point me in the right direction please.

Thanks,
GA
 
T

Tony Toews [MVP]

I've got a report which I can print off without any problems to a pdf
but obviously I get a single pdf with several hundred pages (each
record prints to a new page) but what I want is to print mulitple
documents from one report and hopefully automatically name each one
using the one of the fields from the report.

For a page on how to print a report for a single record and how to
generate reports to attach to emails see the Emailing reports as
attachments from Microsoft Access page at
http://www.granite.ab.ca/access/email/reportsasattachments.htm

Tony
 
G

GA

For a page on how to print a report for a single record and how to
generate reports to attach to emails see the Emailing reports as
attachments from Microsoft Access page at
http://www.granite.ab.ca/access/email/reportsasattachments.htm

Tony

Thanks for that. I am fine printing a report for a single record but I
don't want to do it manually several hundred times.

I am trying to run the report unfiltered but have it print each record
to a new document i.e. not print a document for one record.

GA
 
G

GA

Thanks for that. I am fine printing a report for a single record but I
don't want to do it manually several hundred times.

I am trying to run the report unfiltered but have it print each record
to a new document i.e. not print a document for one record.

GA

Looking at it with a fresh mind. I think what I need to do is to get
some code that will loop through the records and on each occasion
print the report based on the current record in the loop.

Are there any pointers to code that will do that?

GA
 
T

Tony Toews [MVP]

GA said:
Looking at it with a fresh mind. I think what I need to do is to get
some code that will loop through the records and on each occasion
print the report based on the current record in the loop.

Correct. I thought the link I gave you had that info on it as well.
My apologies.

See the Sample Code illustrating looping through a DAO recordset page
at the Access Email FAQ at
http://www.granite.ab.ca/access/email/recordsetloop.htm

Tony
 
G

GA

Correct. I thought the link I gave you had that info on it as well.
My apologies.
See the Sample Code illustrating looping through a DAO recordset page
at the Access Email FAQ at
http://www.granite.ab.ca/access/email/recordsetloop.htm
Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/

Thanks again,

I've almost there with code and tidbits from various places including the
print to pdf from Stephen LeBans site. But one final problem exists. I get
separate pdf's, one for each record and all named correctly but every pdf
contains all pages of the report.

I need somehow to filter the recordset as each record is arrived at within
the loop.

My code is as follows -
-------------------------------
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim DB As Database
Dim RSValues As DAO.Recordset
Dim strDocName As String
Dim blRet As Boolean
Dim field As String

Set DB = CurrentDb()
Set RSValues = DB.OpenRecordset("TableName", dbOpenDynaset,
dbSeeChanges)
strDocName = "ReportName"


RSValues.MoveLast
RSValues.MoveFirst

While Not RSValues.EOF

field = RSValues!FieldName
blRet = ConvertReportToPDF(strDocName, vbNullString, field &
".pdf", False, False, 150, "", "", 0, 0, 0)
RSValues.MoveNext

Wend

Err_Command3_Click:
MsgBox Err.Description

End Sub
 
T

Tony Toews [MVP]

I get
separate pdf's, one for each record and all named correctly but every pdf
contains all pages of the report.

From the page on my initial posting.

However you can not pass a filter or where clause as you would in a
standard Open report command in VBA when outputting the report to a
file. Therefore you must change the filter in the reports OnOpen
event.

Me.Filter = "Shipment SId=" & Forms![Select Load List]![LoadID]
Me.FilterOn = True

Tony
 
G

GA

[email protected](GA) said:
I get
separate pdf's, one for each record and all named correctly but every pdf
contains all pages of the report.

From the page on my initial posting.

However you can not pass a filter or where clause as you would in a
standard Open report command in VBA when outputting the report to a
file. Therefore you must change the filter in the reports OnOpen
event.

Me.Filter = "Shipment SId=" & Forms![Select Load List]![LoadID]
Me.FilterOn = True

Tony


Tony - firstly very many thanks for your help. It is much appreciated.

In the end and out of frustration due to my own shortcomings, I
reverted to the methods I know and I used a form. I used a
parameterised query for the report based on a form control and then
used the form timer to -
1 Print the report
2 Move to next record
3 And If Me.NewRecord stop the timer

Clunky but it worked.
GA
 
T

Tony Toews [MVP]

GA said:
In the end and out of frustration due to my own shortcomings, I
reverted to the methods I know and I used a form. I used a
parameterised query for the report based on a form control and then
used the form timer to -
1 Print the report
2 Move to next record
3 And If Me.NewRecord stop the timer

Clunky but it worked.

Yup, that would work too. Glad you got things going.

Tony
 

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