Run time error 2501 outputto action canceled

RHONDAK72

Board Regular
Joined
Dec 26, 2007
Messages
133
I use Access 2010 and have the Windows 7 OS. I have a form that allows the user to click on a button that will run reports. The reports will automatically run and then output to PDF files that are saved to variable assigned folder paths.

At random, I will get an error "Run time Error 2501, ouput to pdf action was cancelled". It just started occurring yesterday after I decided to rerun some reports after making changes to some of the field values in a related table. Normally, when rerunning the reports, the old PDF reports are replaced with the latest PDF reports and there are no errors.

Then, yesterday, I suddenly began getting the Run time error 2501 at random and the error stated that "the output to PDF action was cancelled. It didn't occur with every PDF report that was being replaced...only with some reports and it varied each time with regard to the reports that it would err out. It wasn't with the same reports each time I ran the process. Very strange. Once I cleared all of the old files from the folders where the reports output to, the errors would stop and everthing would run just fine.

Here is the twist... I reran all reports again this morning two times and I did not get the error one time. I never cleared out the folders and I left the previous files there to be replaced by the newly generated PDF reports. It ran just fine both times with not error 2501.

Has anyone ever had this happen? Anyone know how to fix it or prevent it from happening in the future? The file names and fie paths values are variable based within the output statement:

DoCmd.OutputTo acOutputReport, strReportName, "PDFFormat(*.pdf)", strPath + "\" + strFileName, False, "", , acExportQualityScreen

I appreciate any help. Thanks
 

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.
My group is currently getting this type of error when we save the pdf to a SharePoint Library. Are any of your reports going to SharePoint?
 
Upvote 0
No, I am not not using SharePoint. For my situation, the error occurs at random and that is what is strange. It does not happen with the same report everytime. Sometimes it runs fine without the error. Then at random, the error will occur. It seems to only happen if I'm rerunning the process after it has already been ran. The error seems to only occur for the modules that will run more than 1 report via a Loop method. I have searched and searched and still have not found a solution online. Frustrating!
 
Upvote 0
Well I decided to write some code that first deletes the file if it exists before the Output code runs. Error 2501 is no longer popping up. Yeah!

On Error Resume Next 'Continue code and ignore errorDim strFileToDelete As String
Dim strFileToDelete As String
strFileToDelete = strPath + "\" + strFileName
Kill strFileToDelete
On Error GoTo 0 'Turn normal error handling back on
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,696
Members
449,048
Latest member
81jamesacct

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