Private Sub ExportRptBtn_Click()
Dim ReportName As String
Dim AttachmentName As String
On Error GoTo errhandler
ReportName = "QuoteRpt"
AttachmentName = "Q" & Me.QuoteNumTxtbx & " " & Me.JobNameTxtbx
DoCmd.OpenReport ReportName, acViewReport, , , acHidden
Reports(ReportName).Caption = AttachmentName
DoCmd.SendObject acSendReport, ReportName, acFormatPDF, , , , Me.JobNameTxtbx, , , True
'clean up
Reports(ReportName).Caption = ReportName
Exit Sub
errhandler:
If Err = 2501 Then
'user canceled
Else
MsgBox Err.Description, vbExclamation
End If
'clean up
Reports(ReportName).Caption = ReportName
Exit Sub
End Sub