Automating Report exports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Everyone,

I have a report in my MS Access application that I would like to attach to
an e'mail and send to others.

To do this manually, I preview the report, right click and select Export.
Then save as an RTF file and attach to an e'mail. I need to automate this so
it occurs with a single button click.

In effect the module will need to export the report to an RTF file, then
call the routine that sends the e'mail. The problem I am having is that I am
trying to use the following commands to output the report:

DoCmd.SelectObject ReportName, True
DoCmd.RunCommand acCmdOutputToRTF

When I run this, it does two things taht I don't want it to do.

Firstly it displays the Database Window which I want to keep hidden from the
users

Secondly, Once it has created the .rtf file, it automatically launches MS
Word and displays the results.

I need to find out how to stop the Database window opening and how to stop
MS Word from launching.

Any help or hints would be most appreciated.

TIA,

Alan
 
Try SendObject.
Something like this:

DoCmd.SendObject acSendReport, "Report1", acFormatRTF, _
"(e-mail address removed)",,, "Your report", "Here 'tis", True

If you did need to save the report first, TransferText is another option.
 
Hi Allen,

Thanks a lot. This has solved my problem nicely!

Regards,

Alan

P.S. I guess with a name like that you had to be one of the good guys :-)
 
Mr. Allen Browne,

This is a 2 parter.

I'm trying to adapt the code you provided to fit my situation but am having
difficulties. Reportlistcs is the name of the combobox which contains the
report names. mgrlist is the combobox of the manager I wish to email. In the
Mgrlist the value is "lastname, firstname" however the email that populates
uses a semicolon instead of a comma "lastname; firstname". How can I get the
email to populate the name as it appears exacly in the mgrlist?

Alternatley, If that won't work, I do have a table with the emails listed
for the managers. If the manager name in combobox Mgrlist is "Smith, Jon",
how can I referrence the matching manager name in the table in order to pull
the email address from the Email column in that table?

Also I'd like the subject line to read "Reports for " and then pull a date
from a box named Date2 so it appears as "Reports for 06/30/09". I tried
"Reports for " + [Date2]" but only got an error.

Your help is appreciated ^_^

Code so far:
DoCmd.SendObject acSendReport, Reportlistcs, acFormatRTF, _
mgrlist, , , "Your report ", "", True
 
Back
Top