How to automatically run DoCmd.OutputTo on daily basis

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmartmem
    New Member
    • Feb 2008
    • 87

    #1

    How to automatically run DoCmd.OutputTo on daily basis

    Greetings,

    I have several Access 2007 reports that I regularly export to individual PDF flat files on a web server. I've successfuly created a module sub to export the reports using the DoCmd.OutputTo Macro action, but I can't seem to figure out how to run the macro automatically.

    I can succesfully run the macro below manually (without the IF statements), but have yet to make it work with the IF statement. Ideally, the macro will run automatically at 12:00 noon daily whether or not I have the database open (preferably not).

    Here's the code for what I have so far:

    Code:
    Sub Report_Export()
    If Format(Now(), "hh:mm") = "12:00" Then
    'Now() = Current Date/Time
    'Time set for 12:00 noon
    DoCmd.OutputTo acOutputReport, "SSP&A ROADMAP", acFormatPDF, "http://(web server address)/ez/Documents/SSP&A%20ROADMAP.pdf", False, , , 0
    DoCmd.OutputTo acOutputReport, "Ready to Launch Report_EZLC", acFormatPDF, "http://(web server address)//ez/Documents/Ready%20to%20Launch%20Report_EZLC.pdf", False, , , 0
    DoCmd.OutputTo acOutputReport, "Ready to Launch Report_PFIT", acFormatPDF, "http://(web server address)//ez/Documents/Ready%20to%20Launch%20Report_PFIT.pdf", False, , , 0
    End If
    End Sub
    I'd appreciate guidance from anyone who can help me.

    Regards,

    JM
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    1. Set the Timer Interval Property of the Form to 60000 (1 minute).
    2. Place your code in the Timer() Event of the Form.
    3. Every Minute the code in the Timer () Event will be executed, and when it is exactly !2:00 Noon, the criteria will be met, and the OutPutTo Actions will be initiated.
    4. P.S. - The 'Database' and 'Form' must be 'Opened'.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Alternatively (perhaps a little more complex), design a database that opens a particular form automatically on opem. The code in the OnOpen event of the form does the work you need done and then closes the application.

      Use standard Windows sceduling to invoke the database at noon every day and everything should work as required.

      Comment

      Working...