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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save each page of report as pdf files

Status
Not open for further replies.

JohnBi

Technical User
Feb 14, 2002
6
IT
Can anyone help me with printing a report to pdf files?
Basically I have to produce individual pdf information sheets for each of a long list of report's pages.

I am try with "rtf" suffix, since I am a beginner with Access and programming.


The code is, but I get run-time 13 error:
Private Sub PagetoPDF_Click()
Dim dbf As DAO.Database
Dim rst As DAO.Recordset
Dim strFileName As String
Dim strPathName As String

strPathName = "D:\BovLux\" 'path to change
Set dbf = CurrentDb
Set rst = dbf.OpenRecordset("Invoice") 'Qry Invoice


With rst
If .RecordCount = 0 Then
MsgBox "There are no detailss to print"
Else
.MoveLast
.MoveFirst
Do While Not .EOF
strFileName = strPathName & ![IDOrder] & "_" * ![LastName] '& ".rtf" '-->>>RUN TIME 13 Error
DoCmd.OutputTo acOutputReport, acFormatRTF, strFileName
.MoveNext
Loop
.Close
End If
End With
Set rst = Nothing
End Sub

Thanks for your help.
Regards
John
 
I can't say I've used ! with the With keyword but assuming it works, you have some concantenation problems...

Code:
strFileName = strPathName & ![IDOrder] & "_" & ![LastName] & ".rtf"

You also have some extraneous code...


Code:
Private Sub PagetoPDF_Click()
Dim dbf As DAO.Database
Dim rst As DAO.Recordset
Dim strFileName As String
Dim strPathName As String

    strPathName = "D:\BovLux\"  'path to change
    Set dbf = CurrentDb
    Set rst = dbf.OpenRecordset("Invoice") 'Qry Invoice


    With rst
         Do While Not .EOF
              strFileName = strPathName & ![IDOrder] & "_" & ![LastName] & ".rtf"
              DoCmd.OutputTo acOutputReport, acFormatRTF, strFileName
              .MoveNext
            Loop
        If .RecordCount = 0 Then
            MsgBox "There are no detailss to print"
        End If
        .Close
    End With
    Set rst = Nothing
End Sub


As for the PDF side of it, I have not used Access 2007 with the extensions so I am not sure what needs to be different for that part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top