Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Report to PDF

Status
Not open for further replies.

RANGO03

Programmer
Apr 24, 2003
9
US
Here is what I have so far:


<Begin of code>


Private Sub cmdPrtOnePage()
On Error GoTo Err_cmdPrtOnePage

Dim stDocName As String
Dim db As Database
Dim rs As Recordset
Dim i As Integer

Set db = CurrentDb
Set rs = db.OpenRecordset("Select Project from Project")
rs.MoveLast
rs.MoveFirst

For i = 0 To rs.RecordCount - 1
DoCmd.CopyObject , rs!Project, acReport, "OPW - All Projects"
stDocName = rs!Project
DoCmd.OpenReport stDocName, acNormal, , "Project = '" & rs!Project& '""
DoCmd.DelectObject acReport, stDocName
rs.MoveNext
Next i

Exit_cmdPrtOnePage:
End Sub

Err_cmdPrtOnePage:
MsgBox Err.Description
Resume Exit_cmdPrtOnePage

End Sub

<End of Code>

Basically I have a report with about 50 pages with one record on each page. I want to save each page as a pdf file with the record name as the file name. When I try and run my Module, I receive an error saying my cmdPrtOnePage label is not defined. Can anyone help??
 
Take a look at faq703-2533. The code does exaclty what you want and you only need to wrap it in a "page" loop.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top