473,419 Members | 4,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

2501 Error Out put to Canceled

DJRhino1175
221 128KB
I get the 2501 error stating that the Out put to was canceled without anyone cancelling it. I go to debug and it points to lines 21 and 22.

I do not have any issues running this on my PC, but I have a user that gets this every time he try's to run this code.
I gave his PC full control of the folder the database is in thinking it was a rights issue but that did not help either.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Option Compare Database
  3.  
  4. Private Sub btnMail1_Click()
  5.  
  6. Dim strEMail As String
  7. Dim oOutlook As Object
  8. Dim oMail As Object
  9. Dim strAddr As String
  10. Dim MyDB As DAO.Database
  11. Dim rstEMail As DAO.Recordset
  12. Dim strReportName As String
  13.  
  14. Set oOutlook = CreateObject("Outlook.Application")
  15. Set oMail = oOutlook.CreateItem(0)
  16.  
  17. strReportName = "New ECN Report"
  18.  
  19. gstrFilter = "[ECNID]=" & Me.ECNID
  20.  
  21. DoCmd.OutputTo acOutputReport, "rptECN", acFormatPDF, CurrentProject.Path & _
  22.                "\" & strReportName & ".pdf", , , , acExportQualityPrint
  23.  
  24. 'Retrieve all E-Mail Addressess in tblEMailAddress
  25. Set MyDB = CurrentDb
  26. Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail", dbOpenSnapshot, dbOpenForwardOnly)
  27.  
  28. With rstEMail
  29.   Do While Not .EOF
  30.     'Build the Recipients String
  31.     strEMail = strEMail & ![EmailAddress] & ";"
  32.       .MoveNext
  33.   Loop
  34. End With
  35. '--------------------------------------------------
  36.  
  37. With oMail
  38.   .To = Left$(strEMail, Len(strEMail) - 1)        'Remove Trailing ;
  39.   .Body = "Please review the attached ECN and complete any and all tasks that pertain to you."
  40.   .Subject = Replace(Replace("ECNID |1: |2", "|1", Nz([ECNID], "")), "|2", Nz([NewPN], ""))
  41.     .Display
  42.   .Attachments.Add CurrentProject.Path & "\" & strReportName & ".pdf"
  43.  
  44. End With
  45.  
  46. Set oMail = Nothing
  47. Set oOutlook = Nothing
  48.  
  49. rstEMail.Close
  50. Set rstEMail = Nothing
  51.  
  52. Dim aFile As String
  53. aFile = "M:\Unsecure Share\New ECN System\New ECN Report.pdf"
  54. If Len(Dir$(aFile)) > 0 Then
  55.      Kill aFile
  56. End If
  57. End Sub
Jun 30 '22 #1

✓ answered by rachel gomez

The error 2501 can occur on calling On Close event of report, if there is a problem with the database. While working with reports and Forms error 2501 can be occur, if database go corrupted or changed. There are many reasons for this error like as row deletion in database or changed, data source key field is no longer primary key and relationships are gone, Network Connect Lost of data source etc.


Regards,
Rachel Gomez

0 11946

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: BlackSun | last post by:
most of my rpts don't open even in design mode open with VB gives 2501 error, that should be a sendobject error (related w email...) have you any clue? Access 2003
2
by: John Phelan-Cummings | last post by:
After creating a button on a (parent) form linking to another (child) form, I received the following error when clicking on the command button: "The OpenForm action was canceled" No the child...
33
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on...
8
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report...
1
by: wrcdc | last post by:
Hello. I have a form/radio buttons which chooses and action based on a chosen date from a combox box. Some of these options ask for a windows dialog box to choose input or output filename. All is...
2
by: dkohel | last post by:
What is wrong with the following code? I am trying to filter a form based on the selection of a combobox named cblPRD Dim currentFilter currentFilter = " = '" & Me!cboPRD & "'" Filter =...
7
sassy2009
by: sassy2009 | last post by:
Hello, I am running an insert query from xl spreadsheet using the DoCmd.RunSQL to insert values from the spreadsheet into the Access database. When i run this query it gives an error saying "...
1
by: Aftab Hussain | last post by:
I have following code for a start-up form: Private Sub Form_Timer() 'Close startup form and open logon form DoCmd.Close acForm, "Startup_Form" DoCmd.OpenForm "Logon_Form" End Sub And i am...
7
Brilstern
by: Brilstern | last post by:
This question is very similar to https://bytes.com/topic/access/answers/947462-access-2007-crashes-when-users-cancel-email-while-using-sendobject I am receiving a 2501 error when I cancel my...
1
by: dannymsa | last post by:
Hello, I am trying to a pply a filter on a access 2013 subform, from a query I created to filter data from a table. When I click the bottom to run the filter, I get the following error: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.