Microsoft Office 2007

Posted on 2009-02-20
Medium Priority
Last Modified: 2012-05-06
How to run a Access report into pdf file..
A batch script to run multiple customer report from Access to pdf file separately.

For eg:
Access Summary Rpt: Customer1 , Customer2, Customer3  are in three differnet report sheet.
Export the report into pdf files as Customer1.pdf, Customer2.pdf, Customer3.pdf

Question by:mercybthomas74
  • 3
  • 2
LVL 61

Expert Comment

ID: 23702807
Assuming that you have downloaded the Save as PDF add-in:

You can do this using Access VBA:

    DoCmd.OutputTo acOutputReport, "Customer1", acFormatPDF, "c:\YourFolder\Customer1.pdf"
    DoCmd.OutputTo acOutputReport, "Customer2", acFormatPDF, "c:\YourFolder\Customer2.pdf"
    DoCmd.OutputTo acOutputReport, "Customer3", acFormatPDF, "c:\YourFolder\Customer3.pdf"

If these are your actual report names, you can also use a loop:

Dim I as Integer
For I = 1 to 3
        DoCmd.OutputTo acOutputReport, "Customer" & I , acFormatPDF, "c:\YourFolder\Customer" & I & ".pdf"

Author Comment

ID: 23723308
attached is a sample access db

The Report - Contact: is grouped by ID
The report needs to be saved as 1.pdf and so on

the above one is giving me error

Author Comment

ID: 23723376
The access file could not be attached...

The rpt is grouped by ID
I tried to put the above script on Event Procedure: On Close... gives an error


Author Comment

ID: 23738300
I need to save multiple recordset report from access to snapshot viewer

I got a script for pdf, can you please convert it to snapshot viewer script..please

Private Sub PDF_File_Click()
On Error GoTo Err_PDF_File_Click
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strReport As String
Dim strDocName As String
Dim blRet As Boolean
Dim strDocFolder As String
Dim strFilter As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("ItemHandling_ReportView")
strReport = "Handling Report"
'Path to output PDFs
strDocFolder = "Z:\Phase X - FY08\Efficiency Report\NE Efficiency Rpts\"
Do Until rs.EOF
'Labels the PDF file with the school name
strDocName = strDocFolder & rs!SUVC6 & ".snp"
'Recordsource school id matches report school id
strFilter = "SUVC6 = " & rs!SUVC6
DoCmd.OpenReport strReport, acViewPreview, , strFilter, acHidden
'If Reports(strReport).HasData Then
'Calls the ConvertReportToPDF function
'blRet = ConvertReportToPDF(strReport, vbNullString, strDocName, False, False, 150, "", "", 0, 0, 0)
'End If
DoCmd.Close acReport, strReport
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine..."
'Resume Exit_PDF_File_Click
End Sub

Open in new window

LVL 61

Accepted Solution

mbizup earned 1500 total points
ID: 23740470
You can upload an accdb file if you rename the extension to .txt
Compact the file first, then rename it to .txt and put it in a .Zip file.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New style of hardware planning for Microsoft Exchange server.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question