Link to home
Start Free TrialLog in
Avatar of Rex
RexFlag for United States of America

asked on

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

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

 User generated image
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rex

ASKER

Fantastic! Thank you!
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