Hello Everyone,
Access 2019
I have a button on a form. When clicked, I would like the current record to open in a report I created and export to PDF format.
When I click the button, I get "The output to was canceled." error message.
Here is my code for the button:
==============
Private Sub cmdPrint_Click()
On Error GoTo Err_cmdPrint_Click
If Me.Dirty = True Then
DoCmd.RunCommand acCmdSaveRecord
End If
DoCmd.OpenReport "rptRecord", acViewReport, , "[MASTER_ID] = [Forms]![frmMain]![MASTER_ID]"
DoCmd.OutputTo acOutputReport, "rptRecord", acFormatPDF, "C:\Users\Current Record.pdf", False
DoCmd.Close acReport, "rptRecord"
Exit_cmdPrint_Click:
Exit Sub
Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click
End Sub
=============
Thank you for any and all help!