Results 1 to 12 of 12
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Location
    Maryland, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dreaded 2501 error (A2K SR1)

    Please help! I've tried everything I can think of and every solution that I've found in this forum to stop Run-Time Error 2501.

    My code is simple and works fine except when user Cancels out of email (Outlook).

    Private Sub Send_Email_Click()
    On Error GoTo Err_Send_Email_Click

    If Not IsNull(POC_Email) Then
    DoCmd.SendObject , , acFormatDAP, POC_Email
    End If

    Exit_Send_Email_Click:
    Exit Sub

    Err_Send_Email_Click:

    If Err.Number = 2501 Then
    Exit Sub
    Else
    MsgBox Err.Description
    Resume Exit_Send_Email_Click
    End If

    End Sub

    I've also tried reversing the not-logic and "On Error Resume Next", etc., etc., etc.

    Thanks, LisaZ.

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Dreaded 2501 error (A2K SR1)

    Did you try:
    If Err = 2501 then
    Err.Clear
    Else....

  3. #3
    New Lounger
    Join Date
    Jan 2001
    Location
    Maryland, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dreaded 2501 error (A2K SR1)

    Thanks Mark,
    I did try err.clear in various ways, but nothing worked. It seems that "On Error..." is not even being touched. The error msgbox title is "Microsoft Visual Basic Error" vs. "Microsoft Access Error." I don't think this has anything to do with it. I've blocked this error in the past in different databases, but I've never tried to open Outlook with DoCmd.SendOjbect.

  4. #4
    Star Lounger
    Join Date
    Dec 2001
    Location
    Birmingham, Alabama USA
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dreaded 2501 error (A2K SR1)

    2501 means something was canceled. Try altering your code to what I have below:

    Private Sub Send_Email_Click()
    On Error GoTo Err_Send_Email_Click

    If Not IsNull(POC_Email) Then
    Ricky Hicks
    Microsoft MVP
    Birmingham, Alabama USA

  5. #5
    New Lounger
    Join Date
    Jan 2001
    Location
    Maryland, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dreaded 2501 error (A2K SR1)

    Thanks, but I'm STILL getting the error. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dreaded 2501 error (A2K SR1)

    WHERE are you getting the error? That's the first question that needs to be answered. You're going to have to set some breakpoints and step through the code to see what unhandled event is raising the error. Then we can help you trap it.
    Charlotte

  7. #7
    New Lounger
    Join Date
    Jan 2001
    Location
    Maryland, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dreaded 2501 error (A2K SR1)

    Hi Charlotte,
    I am using DoCmd.SendObject to open Outlook to send email. When I "Cancel" Outlook without sending the email, I get "Run-Time Error 2501 - The SendObject action was cancelled." I've set breakpoints, but cannot get past my DoCmd.SendObject... code. All my error handling code is ignored.

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dreaded 2501 error (A2K SR1)

    The real problem is that SendObject is a sort of blunt instrument and doesn't really allow you any sort of finesse. Have you tried inserting an On Error Resume Next just before the DoCmd.SendObject? Then in the next line, test the Err.Number for a 2501. See if that will trap it.
    Charlotte

  9. #9
    New Lounger
    Join Date
    Jan 2001
    Location
    Maryland, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dreaded 2501 error (A2K SR1)

    Thanks Charlotte,

    That didn't work either. I'm going to try a different approach tomorrow. I'll keep you posted.

    LisaZ.

  10. #10
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Dreaded 2501 error (A2K SR1)

    This is just a hunch, but I suspect that Outlook is actually the culprit here and is generating the 2501 error. That would explain why you are getting an error but never hit your error handling. We send email frequently from Access, but we do it using automation rather than using the DoCmd.SendObject .... For whatever reason, that doesn't seem to generate the kind of error problems you are having. A simple function would look like this:

    Function XXX_SendEmail(MailProp As outSendMail) As Boolean
    On Error GoTo XXX_SendEmail_Error

    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient

    startOutLook
    <font color=448800>' Create the Outlook session.</font color=448800>
    Set objOutlook = CreateObject("Outlook.Application")

    <font color=448800>' Create the message.</font color=448800>
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
    <font color=448800>' Add the To recipient(s) to the message.</font color=448800>
    Set objOutlookRecip = .Recipients.add(MailProp.outTo)
    objOutlookRecip.Type = olTo
    Set objOutlookRecip = .Recipients.add(MailProp.outCc)
    objOutlookRecip.Type = olCC
    Set objOutlookRecip = .Recipients.add(MailProp.outBcc)
    objOutlookRecip.Type = olBCC

    <font color=448800>' Set the Subject, Body, and Importance of the message.</font color=448800>
    .Subject = MailProp.outsSubject
    .Body = MailProp.outsBody

    <font color=448800>' Should we display the message before sending?</font color=448800>
    If MailProp.outDisplayMsg Then
    .Display
    Else
    .Send
    End If
    End With
    Set objOutlook = Nothing

    XXX_SendEmail_Exit:
    Exit Function
    XXX_SendEmail_Error:
    MsgBox Err & " - " & Err.Description
    Resume XXX_SendEmail_Exit
    End Function

    Hopefully this will give you an alternative way to solve your problem, and it also provides more control over what you send - there are a number of properties that this code doesn't use but could.
    Wendell

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dreaded 2501 error (A2K SR1)

    I agree, Wendell. That's what I meant about SendObject being a "blunt instrument". I do it with automation too.
    Charlotte

  12. #12
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dreaded 2501 error (A2K SR1)

    I

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •