Intermittent Error 2501: The Outputto Action was canceled (1 Viewer)


New member
Sep 9, 2016
:banghead: I've made the decision to use the database to create invoices. I have it set up to create the invoice upon clicking, once the invoice is created it saves automatically to my desktop and the creates an email in outlook with the pdf attached. However, I keeping getting the dreaded 2501 error. It will create the record in the database, but not the pdf or the email. The frustrating part is it happens intermittently. I can create 10 invoices with no issues, and then the next 10 will give me the error message every other invoice. I can't seem to find any logical reasoning behind it. Any help would be greatly, greatly appreciated.

'Open the Report Filtering by the WHERE Clause for specific [InitiativeID] Value
DoCmd.OpenReport strRptName, acViewPreview, , "[MbrshipDuesID]=" & DMax("MbrshipDuesID", "[Membership Dues Tracking]", "[CompanyID]=" & Me.CompanyID)
Reports(strRptName).Caption = strReportCaption

'save report to desktop folder
Dim strFile As String
Dim strFile2 As String
strFile = Environ("USERPROFILE") & "\Desktop\DuesInvoices\" & strReportCaption & ".pdf"
strFile2 = Environ("USERPROFILE") & "\Desktop\DuesInvoices\ABC COMPANY Payment Form.pdf"
DoCmd.OutputTo acOutputReport, strRptName, acFormatPDF, strFile, False


Super Moderator
Mar 17, 2004
Hello and welcome to the forum

Does code run in the Report when you execute the DoCmd.OutputTo action? For instance, I would expect this error if I tried to open a report, but an error occurred during the processing of the report making it impossible to display. In your case, however, I see the report should already be open in Preview. I am not sure what happens in this case, but perhaps a whole new instance of the report is opened for the use of OutputTo, or is the already opened report re-processed?

If you have code in the report, can you set a breakpoint in that code, and see if it runs again when the OutputTo action tries to make the PDF? This failure is occurring in the report, and that failure is not being fully reported back to the calling code.

Another thing you can try is, in a code window go to MainMenu->Tools->Options->General(Tab)->Error Trapping(Section)->Break In Class Module (Radio Button) and set this radio button. The report code, in this case, is a Class Module, but the debugger won't stop for errors there by default, but it will if we tell it to. In this case it might reveal the error that is occurring in the report.

Hope this helps,

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom