Solved

Automate Report Run and Email Results

Posted on 2004-09-27
6
236 Views
Last Modified: 2007-11-05
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!
0
Comment
Question by:johnson00
  • 4
  • 2
6 Comments
 
LVL 27

Expert Comment

by:jjafferr
ID: 12164384

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
 
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 12164738
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
http://www.experts-exchange.com/Databases/MS_Access/Q_20563192.html

jaffer
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12166746
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 27

Accepted Solution

by:
jjafferr earned 500 total points
ID: 12167388
I corrected the the timer code, but missed up the sendobject, so here both are corrected:

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#
'Either use SendObject OR any other method from here

            DoCmd.SendObject acSendReport, "YourReportName", acFormatRTF,"Jaffer1@home.com;Jaffer2@home.com","Jaffer3@home.com;Jaffer4@home.com","Jaffer5@home.com;Jaffer6@home.com","This is the Subject","This is the Message",0

    Case Else
            'do nothing
    End Select

End Sub

Note, the following from the above:
TO: Jaffer1@home.com;Jaffer2@home.com
CC: Jaffer3@home.com;Jaffer4@home.com
BCC: Jaffer5@home.com;Jaffer6@home.com

jaffer
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 12167402
I would highly recommend against SendObject as it is rather buggy and has many limitations.
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 12167444
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question