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

Problems emailing a Report

Status
Not open for further replies.

GoinDeep

Technical User
Jan 9, 2003
100
US
I want to set up a command button to email a report from a form. I had the Wizard set up the following:

Dim stDocName As String
stDocName = "rptKnoxWorkOrder"
DoCmd.SendObject acReport, stDocName

It works, but there is three other things I need to happen.

1. I want to filter this report so that only the Current Record is emailed like...stLinkCriteria = "[OrderNumber]=" & Me![txtOrderNumber], but I don't know where or how to use it.

2. The email program I use is GroupWise, but the default is OutLook Express. How can I make it so the report is sent through GroupWise without changing the default email program.

3. I want to automatically send the report as a SnapShot format, but that doesn't seem to be an option?

I thank you in advance for any help.
 
Regarding point 3...

DoCmd.SendObject acSendReport, stDocName, _
"Snapshot Format (*.SNP)", StrEmailAddresses, _
, , strSubject, strMessage, False

Take out or set StrEmailAddresses, strSubject, strMessage as desired.

For point 1, you will need to base your report on a query that contains only the data you want to send. I recommend having your query use a parameter as a control on a form and have the user select that.

For point 2, No, Groupwise must be the default mail program to work with sendobject. The alternative would be to use the Groupwise API (assuming it has one) to send the e-mail. I could help with using Outlook but I've never even used Groupwise.

If you used an API to send mail, you would have to save the file first and then attach it to e-mail. I tried helping someone in one of the access forum's trying to export to a snapshot format, so searching for my username and snapshot should turn it up (I can't remember the outcome). I've seen people get help with a couple e-mail programs here so with a good subject like "Need to Groupwise e-mail via API" you might get the people who know how to help you. Good luck.
 
That helped a lot. I hoping there must be some way of filtering without changing the reports Data source like you would when you DoCmd.OpenReport method then give it Criteria. I use that report for many things. I appreciate all your help.
 
Regarding point 1, you can also put a filter into the report itself. Enable the "Filter On" property and enter the expression you want to use to filter your data. Instead of using one of the fields in your table, use a new filed surrounded by [ ]'s. When the report runs, it will ask you for a response and then run the report.

Alternatively, you can enter a where condition in the Docmd.openreport code line. There is some syntax to watch when you do that, but it will work the same way.

Regarding point 3, You can use the following code that will output an snp format file to the path you want:

DoCmd.OutputTo acOutputReport, "strReportName", acFormatSNP, strPath, False
 
Has anyone everseen the constant acFormatSNP actually work? If yes, what version? It does not work in 97 and I heard it does not in 2000.

As for making a filter a parameter, if that works and you want to use it, be sure not to address the message with sendobject or you'll end up sending too much information to someone sooner or later.
 
The way you showed it worked great in Access 97 for me "Snapshot Format (*.SNP)" It would not accept "acFormatSNP", or any other way I tried. Just "Snapshot Format (*.SNP)"

It appears I am going to have to just open the Report using the DoCmd.OpenReport, , , "WhereCondition", Then OutPut it as a .SNP from there and attach it as an email. I just wanted to make it easier than that.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top