johnson00
asked on
Automate Report Run and Email Results
I have a report created that I would like to run at a specific time each day and email the report to certain recipients. I'm told this is possible, but need to know how to set it up. Thanks!
Ok, this is the correct code:
Private Sub Form_Timer()
'Quit the program at 10:30pm if the program is still open
Dim TheTime As Date
TheTime = Format(Now(), "hh:mm")
Select Case TheTime
Case #10:30:00 PM#
DoCmd.OutputTo acOutputReport, "YourReportName", acFormatRTF, "c:\YourFile.rtf", False
Case Else
'do nothing
End Select
End Sub
for other options of sending emails, please see
https://www.experts-exchange.com/questions/20563192/Sending-mail-attachments-from-Access-2000-through-Outlook-Express.html
jaffer
Private Sub Form_Timer()
'Quit the program at 10:30pm if the program is still open
Dim TheTime As Date
TheTime = Format(Now(), "hh:mm")
Select Case TheTime
Case #10:30:00 PM#
DoCmd.OutputTo acOutputReport, "YourReportName", acFormatRTF, "c:\YourFile.rtf", False
Case Else
'do nothing
End Select
End Sub
for other options of sending emails, please see
https://www.experts-exchange.com/questions/20563192/Sending-mail-attachments-from-Access-2000-through-Outlook-Express.html
jaffer
Have a look here:
http://www.granite.ab.ca/access/email.htm
http://www.granite.ab.ca/access/email.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would highly recommend against SendObject as it is rather buggy and has many limitations.
Shane, don't you ever sleep man!
I agree, But I had to post my last post because I messed up in the earlier one.
One more thing to look at is the Outlook security,
if you want to automate the sending automatically at odd times when you are not around the PC,
then you should look at options other than Outlook.
if you want to use Outlook, then I would recommend you using ClickYes form http://www.contextmagic.com/express-clickyes/
jaffer
I agree, But I had to post my last post because I messed up in the earlier one.
One more thing to look at is the Outlook security,
if you want to automate the sending automatically at odd times when you are not around the PC,
then you should look at options other than Outlook.
if you want to use Outlook, then I would recommend you using ClickYes form http://www.contextmagic.com/express-clickyes/
jaffer
Have a Form Open, in the Timer, set it so that it checks if the time is what you want , then let it run the Report and Send the email/s
1- Form
Set the timer to say 50000 (50 seconds),
On the On Timer of the Form have the following code:
'Assuming you want to print/email at 10pm
if timer="22:00" then
docmd.sendobject YourReportName, To, Subject, Body 'Please correct the syntax
endif
in the syntax you can put multiple recipients too, just search for sendobject in Access help,
You can use Outlook too.
jaffer