Docmd.outputto Error
Contents |
Posters Today's Posts Search Community Links Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts Tag
The Outputto Action Was Cancelled Access 2010
Search Advanced Search Find All Thanked Posts Go to Page... the outputto action was cancelled access 2007 Page 1 of 2 1 2 > Thread Tools Rating: Display Modes 09-30-2011, 06:06 AM #1
The Outputto Action Was Cancelled Pdf
justin198z28 Newly Registered User Join Date: Sep 2011 Posts: 4 Thanks: 2 Thanked 1 Time in 1 Post runtime error 2501 outputto action was cancelled with access vb macro runtime error 2501 openform action was canceled Hi! I'm struggling with a vb macro in access 2007 that returns a "runtime error 2501 outputto action was cancelled". The codes is intended to break up a 1690 page report into 338 five page pdfs, name them, and save in a file structure it creates. Unfortunately it errors when it finishes creating the first pdf - the debugger highlights access can't save the output data to the file you've selected the DoCmd.OutputTo acOutputReport line. I've tried different computers and uninstalling/reinstalling printer drivers. I've added error handling to ignore error 2501 but the code then runs but the pdfs and folder structure is never produced. This code worked the last time the report was run a year ago. I've inherited this project from someone who left the company and I have to admit I have almost no knowledge of vb code. Any idea what the problem is? Option Compare Database Option Explicit Private Sub CreateReports_Click() Dim cn As ADODB.Connection Dim rsDistricts As ADODB.Recordset Set cn = CurrentProject.Connection Set rsDistricts = cn.Execute("SELECT [District_Code], [AGENCY_KEY], [AGENCY_NAME] FROM District_List") Do Until rsDistricts.EOF 'Open report for a specific district DoCmd.OpenReport "JUSTIN_District_Report_Template for 2010-11 9-27", acViewPreview, , "[District_Code]='" & _ rsDistricts![District_Code] & "'", acWindowNormal 'Output report to pdf file DoCmd.OutputTo acOutputReport, "JUSTIN_District_Report_Template for 2010-11 9-27", acFormatPDF, _ "G:\OEA\TSH\ACCESS for ELLs Data\SecureReports\AMAO Reports\" & rsDistricts![AGENCY_KEY] & "\999999\2010_11\" & rsDistricts![AGENCY_NAME] & "_" & rsDistricts![District_Code] & "_ELL_AMAO_2010-11.pdf", , , , acExportQualityPrint 'Close report DoCmd.Close acReport, "JUSTIN_District_Report_Template for 2010-11 9-27" rsDistricts.MoveNext Loop cn.Close End Sub
360 games PC games
Run-time Error '2501' The Openreport Action Was Canceled
Windows games Windows phone games Entertainment All Entertainment docmd.outputto acoutputreport Movies & TV Music Business & Education Business Students & educators
Access Error 2501
Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet http://www.access-programmers.co.uk/forums/showthread.php?t=216260 Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Lumia All https://support.microsoft.com/en-us/kb/226526 Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting http://stackoverflow.com/questions/1111825/handling-an-output-error-in-access ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a http://www.dbforums.com/showthread.php?1695619-OutPut-to-Command-Error-2051 minute: Sign up Handling an output error in Access up vote 0 down vote favorite I'm generating a query and report through VBA. I have an option of asking the user if they want to output the report as a snapshot. action was I first ask them if they want to make a snap shot. If they say no, nothing happens. If they say yes, they get a prompt asking where they want to save it. Everything works great except if they say yes and then click Cancel on the prompt, it raises a runtime error 2501 saying the report action was cancelled. Here is the code. DoCmd.OpenReport "CONCERNS", acViewPreview, lstFee.Value & " DETAILS" If MsgBox("Do you wish to create a snapshot of this report?", vbQuestion the outputto action + vbYesNo) = vbYes Then DoCmd.OutputTo acReport, "CONCERNS", "SnapshotFormat(*.snp)", "" End If This is also the end of my procedure so I don't really care if an error happens here since all the important stuff happened already. I just know some monkey somewhere will flip if they ever see it. Is there a way to handle this error? On Error Resume Next is not an option because that would make debugging a nightmare in the future. It sounds like I'm looking for something like a Try/Catch but I don't think VBA supports that. ms-access vba error-handling share|improve this question edited Jul 10 '09 at 20:40 asked Jul 10 '09 at 20:31 mandroid 97231328 add a comment| 3 Answers 3 active oldest votes up vote 0 down vote accepted There are (at least) two ways to handle this. 1> get the filename and handle possible cancellation in a step before sending the report snapshot. I haven't done this recently but there's another way to generate the snapshot report than the DoCmd.OutputTo command, or some variation that doesn't require the command itself to use a file dialog. I generated report snapshots in an old application and didn't have to ask the user for a filename. I'll try to find the code and show an example. 2> use On Error Resume Next, but only right before the DoCmd.OutputTo routine, then see if there's an error, then turn it back off: If MsgBox("Do you wish to create a s
visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 12 of 12 Thread: OutPut to Command Error 2051 Tweet Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 08-16-13,06:26 #1 Vickles View Profile View Forum Posts Registered User Join Date Nov 2012 Posts 20 Unanswered: OutPut to Command Error 2051 Hi, Please can someone help me figure out why I am getting Error 2051 "Outputto action was cancelled" My coding is as follows: Private Sub Command77_Click() If Me.FolderName = "January" Then Dir ("\\DISKSTATION\Innovative Physics\Admin\Invoices, Quotes, Credit Notes and Purchase Orders\Invoices Sent\2013\January\" & "Job#" & Space(3) & Me.Job_Number & Space(3) & Me.Job_Description & "\" & "Outgoing") End If Dim MyFileName As String Dim MyPath As String MyPath = "\\DISKSTATION\Innovative Physics\Admin\Invoices, Quotes, Credit Notes and Purchase Orders\Invoices Sent\2013\January\" MyFileName = "IPL" & Space(1) & Me.Company_Code & Space(1) & "13" & Space(2) & Me.Sales_Invoice & ".pdf" DoCmd.OutputTo acOutputReport, "rptSalesInvoice", acFormatPDF, MyPath & MyFileName, False End Sub I have looked through many threads and have been able to solve this issue. Reply With Quote 08-16-13,10:01 #2 Burrina View Profile View Forum Posts Registered User Join Date Nov 2011 Posts 413 If Err.Number = 2051 Then End If Reply With Quote 08-16-13,10:08 #3 Vickles View Profile View Forum Posts Registered User Join Date Nov 2012 Posts 20 Thank you for the quick reply. I have tried that...still get the error message. Reply With Quote 08-16-13,10:27 #4 Burrina View Profile View Forum Posts Registered User Join Date Nov 2011 Posts 413 Try adding this to the bottom of your code: Error_Handler: Select Case Err.Number Case 2501 Err.Clear Resume Error_Handler_Exit Case Else MsgBox "Error No. " & Err.Number & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error" Err.Clear Resume Error_Handler_Exit End Select Reply With Quote 08-16-13,10:44 #5 Vickles View Profile View Forum Posts Registered User Join Date Nov 2012 Posts 20 Thank you for your help. I get the error message label not defined on Resume Error_Handler_Exit Reply With Quote 08-16-13,11:58 #6 Burrina View Profile View Forum Posts Registered User Join Date Nov 2011 Posts 413 Code should have read 2051 instead of 2501, My Bad! Please correct and le