Error 2501

Amy35

Registered User.
Local time
Today, 19:48
Joined
Mar 12, 2002
Messages
53
I'm running office 2000 with A2K
I have a button on my form that when pressed takes some info from the form and places it in the body of an email. Everything works fine if the user does what they are supposed to...but we all know we can't count on that.

When outlook opens and the user decides they don't want to send an email after all and just closes outlook, this error pops up... "Run Time Error 2501 The SendObject Action was cancelled" then there's END and DEBUG.

I do not want the user to be able to hit DEBUG and get into my code. Here's my code:

Private Sub cmdEmail_Click()
MsgBox "Please be patient this will take a minute", vbInformation, "Be Patient"
DoCmd.SendObject , , , , , , "Trouble Ticket", _
"Ticket Date: " & Me.TicketDate & vbCrLf & "User: " & Me.UserFirstName & vbCrLf & _
"Problem Description: " & Me.ProblemDescription, False
End Sub

I've tried using if err.code = 2501
On err goto
and others, I don't think I have the syntax or order right though.

Any ideas? Thanks!

Amy
 
Try this Amy

Private Sub cmdEmail_Click()

On Error Goto ErrorHandler

MsgBox "Please be patient this will take a minute", vbInformation, "Be Patient"
DoCmd.SendObject , , , , , , "Trouble Ticket", _
"Ticket Date: " & Me.TicketDate & vbCrLf & "User: " & Me.UserFirstName & vbCrLf & _
"Problem Description: " & Me.ProblemDescription, False

Exit:
Exit Sub

ErrorHandler:
Select Case Err.Number

Case 2501 'Trape Error 2501
MsgBox "E-Mail Was Cancelled",,"Cancelled"
Resume Exit

Case Else
MsgBox Err.Description 'Will show every other error
Resume Exit

End Select
End Sub
 
Thanks! That looks great.
Only one problem I get a compile error/syntax error and it stops on the
Exit:
line
I do know this is probably something small, I'm not too experienced with code so I don't know how that line should look. And of course when I hit "help", I get a blank screen/stare back.

Thank you for your help.

Amy
 
Sorry Amy, my fault, Access is trying to Exit the : (Reserved word
smile.gif
). Change The Exit: to ForceExit: or whatever then change

Resume Exit to Resume ForceExit

That should fix it
 
THANK YOU! That worked great...thanks so much, it was exactly what I wanted it to do!

Amy
 

Users who are viewing this thread

Back
Top Bottom