Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

“SendObject” question. Possible to disable prompt? 1

Status
Not open for further replies.

Spyder757

Technical User
Aug 29, 2002
129
US
I’ve got a database and I’d really like it to be as easy as possible on the end users to export a report in snapshot format, open a new piece of mail from outlook, and attach the report.

I decided to do this using the SendObject command. My code works fine for exporting the report and attaching it to a new piece of mail. My problem is if the user decides NOT to send the message and closes the new mail out then the database generates an error message box explaining the send object didn’t occur and prompts to debug the code.

Basically I’d like someone to look over my code and offer suggestions to disable that message box. I’ve tried to turn off warnings but it had no effect on this particular problem.

Private Sub Button01_Click()
On Error GoTo Err_Button01_Click

DoCmd.SetWarnings False
DoCmd.SendObject acReport, "Rpt_MainReport", "SnapshotFormat(*.snp)", "", "", "", "Testing", "", True, ""

Exit_Button01_Click:
Exit Sub

Err_Button01_Click:
MsgBox Err.Description
Resume Exit_Button01_Click
End Sub
 
Hi!

That's probably the 2501, you cancelled the previous operation (it's nice if you could incluce the exact errormsg, as quoted in this faq181-2886 (#14)). Since you have an errorhandling routine, you shouldn't get prompted to debug, but only get the ordinary errormsg generated by the msgbox in the error handling routine. But without the errormsg, it's a bit of guesswork.

Try altering the errorroutine to something like this:

[tt]Err_Button01_Click:
if err.number <>2501 then
MsgBox Err.Description
end if
Resume Exit_Button01_Click
End Sub[/tt]

Don't know if it matters, but I never send empty strings with different methods of the docmd object:

[tt]DoCmd.SendObject acReport, "Rpt_MainReport", "SnapshotFormat(*.snp)",,,,"Testing",, True[/tt]

And - if your turning the warnings off (which shouldn't be necessary here) be sure to turn them on againg:

[tt]docmd.setwarnings true[/tt]

Roy-Vidar
 
Well you are correct, When I added the error handling it no longer prompted to debug, it simply poped up the message box that you had to "ok" through.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top