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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing Reports Automatically

Status
Not open for further replies.

darude

Programmer
Jun 23, 2003
138
US
Hi,
I have a reports database that should email a report to a specific party. That works fine. It should then run a report that gets stored in a folder on our network. When the second DoCmd runs I get this error message:
Run-time error 2046
Command or action 'Output To' isn't available now.

Below is the code I'm using, can anyone help me figure out why this isn't working. Thank you in advance.



Private Sub cmdByMonth_Click()
Dim txtTo, txtCC, txtBCC, txtSubject, txtMessage As String

txtTo = "ManagersReports"
txtCC = ""
txtBCC = ""
txtSubject = "WBLP Comparison by Years"
txtMessage = ""

DoCmd.SendObject acSendReport, "WBLPComparisonbyYrs", "SnapshotFormat(*.snp)", _
txtTo, txtCC, txtBCC, txtSubject, txtMessage, False

DoCmd.OutputTo acOutputReport, "WBLPComparisonbyYrs", "SnapshotFormat(*.snp)", _
"\\Bospicfs01\Groups\Databases_Shared\Reports\Weekly Placements\WBLP Comparison by Years.snp", False, ""

End Sub
 
Why run your report twice??

Paste your OutputTo code as a function statement in a module. Then see my last post in thread705-563408 for an example of attaching an external document to an e-mail message.

Hope this helps....

Hoc nomen meum verum non est.
 
Thank you Cosmo, I will definitely try that. It looks like the answer I have been looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top