View Full Version : Click button in form, report is attached to e-mail...


thiazi
04-14-2007, 07:28 AM
I have several forms working that currently generate working reports. I'm generating the report through DoCmd.OpenReport function, then my report name, then acViewPreview.

What sort of code would I need to put in a command button so when it is clicked on the form itself, the report is automatically generated and attached to an outgoing e-mail? Ideally, without the report ever being presented on the screen, but if it is displayed, that's not a problem.

All of my users will be using Microsoft Outlook, if it matters. Also, I have a combo box on one of the forms that allows the user to pick a person to run the report on. Is there anyway to automatically populate the "To:" line in the email with the persons name (global address book will convert that to their email address automatically)?

pbaldy
04-14-2007, 09:02 AM
Look at

DoCmd.SendObject

thiazi
04-14-2007, 09:50 AM
Well that was super easy.. thank you!! When I exited the message and clicked on Cancel, I got a SendObject failed message from Access. Is this normal?

thiazi
04-14-2007, 09:55 AM
Nevermind - it helps to have error handling! :)