Email link error in form

dmbfan73

Registered User.
Local time
Today, 21:50
Joined
Nov 21, 2002
Messages
13
I have some email fields set up in a form so that the user can click on an address and have it automatically open up outlook and fill in the "To:" field. Everything works fine, except if you decide not to sent the message and close outlook, I get the following visual basic error:

Run-time error '2501':

The SendObject action was canceled.

Instead of this popping up and opening visual basic, I'd like to have a simple message box pop up that says "the send object action was canceled" and the user can just hit "ok" and it takes them back to the form, instead of launching VB.

In another form I have an option to email a report, and when I hit the X on that one, it just gives a simple error message and returns the user back to the form. I've compared the code for both, and I can't see any difference.

Any help is greatly appreciated!
 
Why don't you trap the error.
Put this in whatever Sub you are taken to when the debug window opens...

Private Sub YourSubName
On Error GoTo OutLookErr

'code goes here
'and then at the very end of the SAME Sub Procedure add this...

OutLookErr_Exit:
Exit Sub

OutLookErr:

If Err.Number = 2501 Then
MsgBox Err.Description
End If

GoTo OutLookErr_Exit

End Sub

Hope this helps
 
sambo,
thanks so much, it worked exactly how I wanted!!!
 

Users who are viewing this thread

Back
Top Bottom