By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,958 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,958 IT Pros & Developers. It's quick & easy.

How to automatically run DoCmd.OutputTo on daily basis

P: 87

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:

Expand|Select|Wrap|Line Numbers
  1. Sub Report_Export()
  2. If Format(Now(), "hh:mm") = "12:00" Then
  3. 'Now() = Current Date/Time
  4. 'Time set for 12:00 noon
  5. DoCmd.OutputTo acOutputReport, "SSP&A ROADMAP", acFormatPDF, "http://(web server address)/ez/Documents/SSP&A%20ROADMAP.pdf", False, , , 0
  6. DoCmd.OutputTo acOutputReport, "Ready to Launch Report_EZLC", acFormatPDF, "http://(web server address)//ez/Documents/Ready%20to%20Launch%20Report_EZLC.pdf", False, , , 0
  7. DoCmd.OutputTo acOutputReport, "Ready to Launch Report_PFIT", acFormatPDF, "http://(web server address)//ez/Documents/Ready%20to%20Launch%20Report_PFIT.pdf", False, , , 0
  8. End If
  9. End Sub
I'd appreciate guidance from anyone who can help me.


Aug 1 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 8,692
  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'.
Aug 2 '08 #2

Expert Mod 15k+
P: 31,758
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.
Aug 10 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.