Cancelling an email using SendObject

R

RonaldoOneNil

I have searched this forum and found the answer to my problem but it does n't
seem to work for me.
I am using access 2003 and have a button on a form to send an email. The
code behind the button is below.

Private Sub cmdEmail_Click()
On Error GoTo Err_Email

DoCmd.SendObject acSendReport, "Invoice", acFormatRTF, Me.EmailTo, , ,
Me.EmailSubject, , True
Exit Sub

Err_Email:
If Err.Number = 2501 Then
Err.Clear
Exit Sub
Else
MsgBox Err.Number & vbCrLf & Err.Description
Exit Sub
End If
End Sub

If I cancel the email and do not send it, then I get the following message
The SendObject action was cancelled
You used a method of the DoCmd object to carry out an action in Visual Basic
but then clicked cancel in the dialog box.
For example .....

In other words my on error is not trapping the error.
Also, it hangs my form and I can't click any other buttons, it just beeps at
me.
If I try and close Access down, I get the message

You can't exit the system now.
If you're running a Visual Basic module that is using OLE or DDE, you may
need to interupt the module.

Anybody seen this before or know how to get round it
 

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

Top