Why is my Report Printing (VBA)

QandAdam

New Member
Joined
Jan 12, 2019
Messages
30
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?

Code:
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
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,814
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:

Watch MrExcel Video

Forum statistics

Threads
1,095,840
Messages
5,446,815
Members
405,416
Latest member
galoli

This Week's Hot Topics

Top