Error Trapping

P

petera

Someone please help! I'm sending an email using
DoCmd.SendObject. When the email is generated, if you
delete the email without sending it, Access generates an
error 2501 saying The SendObject action was cancelled.
I'm trying to trap that error code, ignore it and
continue... this is the code I've generated.

Private sub Send_Email()
On Error GoTo Send_Email_Error
DoCmd.SendObject blah! blah! blah!

Send_Email_Exit:
Exit Sub

Send_Email_Error:
if err.number = 2501 then
Resume Send_Email_Exit
End Sub

once the DoCmd.SendObject is executed, and the email is
cancelled, it never recognizes the eror by going to the
Send_Email_Error paragraph...what am I doing wrong?

Thanks in advance.
 
P

Paul

You're missing an End If for the line after your Resume

--
Michael Badnarik for President '04
Libertarian...the freedom party
www.lp.org
www.badnarik.org

"If you are in prison and your chances are 50% for execution by electric
chair, 45% for execution by lethal injection, and 5% for escape, are you
just going to vote for the chair because it is the likeliest outcome?" Vote
Libertarian and live to be free.
 
R

Rick Brandt

petera said:
Someone please help! I'm sending an email using
DoCmd.SendObject. When the email is generated, if you
delete the email without sending it, Access generates an
error 2501 saying The SendObject action was cancelled.
I'm trying to trap that error code, ignore it and
continue... this is the code I've generated.

Private sub Send_Email()
On Error GoTo Send_Email_Error
DoCmd.SendObject blah! blah! blah!

Send_Email_Exit:
Exit Sub

Send_Email_Error:
if err.number = 2501 then
Resume Send_Email_Exit
End Sub

once the DoCmd.SendObject is executed, and the email is
cancelled, it never recognizes the eror by going to the
Send_Email_Error paragraph...what am I doing wrong?

How do you know it's not branching to Send_Mail_Error? You have nothing
going on there except to branch to Send_Mail_Exit so nothing happening
is what's "supposed" to happen.
 
G

Guest

you're correct, however the code in the form does have
it...that's not causing the problem, do you have any
other idea?
 
G

Guest

here it is....

Private Sub send_email()
On Error GoTo send_email_error
DoCmd.SendObject acSendNoObject, "notify email",
acFormatHTML, EmailTO, EmailCC, EmailBCC, "An Issue has
been updated or submitted by " & Me.SubmittedBy & " for "
& Me.SubmittedTo, strBody

send_email_exit:
Exit Sub

send_email_error:
MsgBox Err.Number & " " & Err.Description
Resume send_email_exit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top