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
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top