Why is my Report Printing (VBA)
Results 1 to 2 of 2

Thread: Why is my Report Printing (VBA)
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jan 2019
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Default Why is my Report Printing (VBA)

    I've got the code below to save a report as a PDF at the click of a button. The button works fine, but whenever it is clicked, the report is also printed out. Does anyone know why this would be and is there a way to stop it from printing?

    Private Sub Command271_Click()
    Dim ReportName As String
    Dim URNCriteria As String
    Dim FileName As String
    Dim FilePath As String
    ReportName = "AgreementAVDF"
    URNCriteria = "Table1.[URN] = Forms![frm1]![URN]"
    FileName = "AgreementAVDF" & " - " & Me.[Company Name]
    FilePath = "\\scc01\Data\Backup\Folder 1\Folder 2\Folder 3\Agreements\" & FileName & ".pdf"
    DoCmd.OpenReport ReportName, acViewNormal, URNCriteria
    DoCmd.OutputTo acOutputReport, "AgreementAVDF", acFormatPDF, FilePath
    DoCmd.Close acReport, "AgreementAVDF"
    End Sub

  2. #2
    Board Regular
    Join Date
    Jun 2015
    Ontario, Canada
    Post Thanks / Like
    1 Post(s)
    0 Thread(s)

    Default Re: Why is my Report Printing (VBA)

    acViewNormal sends the report directly to the printer. If you only need to output it as pdf, you don't need to open the report. If you need to open the report but don't want to print use acViewPreview
    Last edited by Micron; Jun 15th, 2019 at 07:21 PM. Reason: spelin and gramur and correction
    Tips for posting problems:
    1) "doesn't work" doesn't help. Post error message text/numbers and/or state what's happening.
    2) if posting code or sql, use code tags; specify on which code line errors occur, if applicable
    3) try to be specific; assume we know nothing about your issue - because we don't!

    Make all suggested changes in copies of your database or to its objects.

    "1 out of 1010 people understand binary. The other 1001 don't."

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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