Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Sep 2008
    Location
    Medway, Kent, United Kingdom
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Close Email (2003)

    Morning all

    My database has a button on the main menu with the caption ‘Got a question?’ The click event opens an email addressed to me into which the user can type a question or just make a disparaging comment if they choose!

    Once open if the email is closed without sending I get the error message Run Time Error 2501 – The SendObject action was cancelled.

    So I put this at the end of the sub which I adapted from the error handling code in another sub:

    Exit_CmdEmail_Click:
    Exit Sub

    Err_CmdEmail_Click:
    MsgBox Err.Description
    Resume Exit_CmdEmail_Click

    But to no avail. So I remed out the MsgBox line still to no avail.

    Can anyone suggest a nice neat line of code that will just close the email?

    Thanks

    Regards

    Graeme

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Close Email (2003)

    Error 2501 can usually be ignored safely, so you could change the error handling section like this:

    Err_CmdEmail_Click:
    If Err = 2501 Then
    ' User cancelled - just ignore
    Else
    ' Otherwise display error message
    MsgBox Err.Description, vbExclamation
    End If
    Resume Exit_CmdEmail_Click
    End Sub

  3. #3
    New Lounger
    Join Date
    Sep 2008
    Location
    Medway, Kent, United Kingdom
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Close Email (2003)

    Thanks Hans

    I put the code in but still get the same error. Here's the sub,

    Private Sub CmdEmail_Click()

    DoCmd.SendObject _
    , _
    , _
    , _
    "graeme.durden@edfenergy.com", _
    , _
    , _
    "DataBase Question", _
    "Type your Database question here................", _
    True

    Exit_CmdEmail_Click:
    Exit Sub

    Err_CmdEmail_Click:
    If Err = 2501 Then
    ' User cancelled - just ignore
    Else
    ' Otherwise display error message
    MsgBox Err.Description, vbExclamation
    End If
    Resume Exit_CmdEmail_Click


    End Sub

    Have I put a a typo somewhere?

    Regards

    Graeme

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Close Email (2003)

    The error handler will only work if you activate it!

    You should insert a line

    On Error GoTo Err_CmdEmail_Click

    at the beginning, below Private Sub ...

  5. #5
    New Lounger
    Join Date
    Sep 2008
    Location
    Medway, Kent, United Kingdom
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Close Email (2003)

    Yeah, that's a fair observation!

    Code now inserted, error handler activated, error now successfully being handled!

    Thank you very much Hans

    Regards

    Graeme

Posting Permissions

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