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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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