Solved

Automate Report Run and Email Results

Posted on 2004-09-27
6
232 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now