Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How avoid error message when not sending email

Posted on 2014-11-06
4
Medium Priority
?
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

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…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

719 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