using autoexec macro and windows scheduled task to run queries

Posted on 2010-08-20
Last Modified: 2012-05-10
I use auto exec macro, module and windows scheduled tasks to run a query.
Now I want to run two more queries - each at a different time- is that possible?
Public Function startprog()
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdate"
DoCmd.Quit acQuitSaveNone
End Function
(action) RUN CODE      
function name

that code is what I am using,
thank you
Question by:davetough
LVL 119

Accepted Solution

Rey Obrero earned 167 total points
ID: 33487213
create another .bat file that will run a macro and use the  scheduled tasks to set the time to run the .bat file

Assisted Solution

bartjoosen earned 167 total points
ID: 33487767
You can make 3 macros, setting 3 entries in the task scheduler,
or maybe set the queries after each other in 1 macro:
Public Function startprog()
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdate1"
DoCmd.OpenQuery "qryUpdate2"
DoCmd.OpenQuery "qryUpdate3"
DoCmd.Quit acQuitSaveNone
End Function

LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 166 total points
ID: 33487920
Or you could use the scheduler to kick off the application at three different times, and let the application decide which query to run depending on the time.

If TimeValue(Now()) Between #01:30# AND #01:45# Then
    docmd.Openquery "qryUpdate1"
Elseif  TimeValue(Now()) Between #02:30# AND #02:45# Then
    docmd.Openquery "qryUpdate2"
Elseif  TimeValue(Now()) Between #03:30# AND #04:45# Then
    docmd.Openquery "qryUpdate1"

You could put this code in the Load event of your Startup form, rather than an autoexec macro (although I'm sure there are ways to do If/Then statements in macros, I've never felt the need to learn how).

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

747 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