?
Solved

Is There a Way to Force the E-mail in a DoCmd.SendObject Command?

Posted on 2011-03-24
3
Medium Priority
?
377 Views
Last Modified: 2012-06-21
I am using the following code...
DoCmd.SendObject acSendNoObject, , , semail, , , "Level 2 Product CAR Root Cause Report", sBody
...to send an e-mail when a command button is ciicked.

However, if the user closes the e-mail without clicking Send, it crashes and I get the following error saying the Object was cancelled.

Is there a way to force the e-mil through without requiring the user to click Send?

...or....is there a way to keep the code from crashing like that if they do cancel the object?

Thanks

 Error When e-mail cancelled
0
Comment
Question by:Rex85
[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
3 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 35209748
Try this:

On Error Resume Next
DoCmd.SendObject acSendNoObject, , , semail, , , "Level 2 Product CAR Root Cause Report", sBody

Select Case Err.Number
    Case 0
      '  no error occurred
    Case 2501
        Err.Clear ' ignore - user cancelled
    Case Else
        'MsgBox " Unexpected error  " & Err.Number & "  " Err.Description
End Select

 ' continue on ...

mx
0
 

Author Closing Comment

by:Rex85
ID: 35209803
Fantastic! Thank you!
0
 
LVL 75
ID: 35209836
You are welcome.  Note at a similar thing can happen when opening reports say from a 'Report Setup' Form ... and the report has no data, and user closes the report.

DoCmd.OpenReport "YourCoolReport", acPreview

Select Case Err.Number
    Case 0
      '  no error occurred
    Case 2501
        Err.Clear ' ignore - user cancelled
    Case Else
        'MsgBox " Unexpected error  " & Err.Number & "  " Err.Description
End Select
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

800 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