Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012

    Question Unanswered: Output Report in PDF Format with Customized File Name


    I am trying to output a report using DoCmd.OutputTo with a customized file name based on a control on a form that is open. Not only can I not get my code to work, but my output goes to the printer! My intention is not to print the report but to save it as a pdf file with a filename that is customized and then have adobe reader automatically open the report for viewing. Please see my code below:

    Private Sub Command8_Click()
    On Error GoTo Err_Command8_Click

    Dim OutputFileName As String

    OutputFileName = "All_Queries_by_Study_And_Site" & Me.Combo4 '

    DoCmd.OpenReport "All_Queries_by_Study_And_Site", acViewNormal, , , acWindowNormal
    DoCmd.OutputTo acOutputReport, "All_Queries_by_Study_And_Site", acFormatPDF, OutputFileName, True, , , acExportQualityPrint

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command8_Click

    End Sub

    Any and all help is very much appreciated!
    Last edited by doopml; 12-17-12 at 15:05.

  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    Well, the OpenReport line is what's printing it. You don't need that line based on what you're doing. You can use FollowHyperlink or Shell to open the PDF file after its created.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts