Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How avoid error message when not sending email

Posted on 2014-11-06
4
Medium Priority
?
163 Views
Last Modified: 2014-11-06
I have the following code on an onclick event of an email hyperlink in a form.

Private Sub txtEmail_Click()
Dim strEmail As String

 If IsNull(Me.txtEmail) Then
 MsgBox ("There is no email address shown")
 Exit Sub
 ElseIf Me.txtEmail = " " Then
 MsgBox ("There is no email address shown")
 Exit Sub
 End If
 strEmail = Me.txtEmail
 DoCmd.SendObject , , , strEmail, , , , , True

End Sub

Open in new window


But if the user closes the email window and doesn't send an email we get an error:

"The sendobject action was cancelled"

How can we not get this error message?
0
Comment
Question by:SteveL13
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:Shaun Kline
ID: 40426835
Was your intent to have an email sent when someone clicks the txtEmail control?
0
 

Author Comment

by:SteveL13
ID: 40426843
Yes.  But when the email window opens and if the user changes their mind and doesn't send an email the error appears.
0
 
LVL 27

Accepted Solution

by:
Shaun Kline earned 2000 total points
ID: 40426902
You could wrap that line of code in an On Error Resume Next statement. Something like:

strEmail = Me.txtEmail

On Error Resume Next
DoCmd.SendObject , , , strEmail, , , , , True
If Err.Number <> 0 Then
' Handle the error
End If
On Error Goto 0

Open in new window

0
 

Author Closing Comment

by:SteveL13
ID: 40426940
That did it.  Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question