Microsoft Office 2007

Posted on 2009-02-20
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
    LVL 61

    Expert Comment

    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

    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

    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

    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

    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

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    My experience with Windows 10 over a one year period and suggestions for smooth operation
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now