Rex
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER