Solved

using autoexec macro and windows scheduled task to run queries

Posted on 2010-08-20
3
593 Views
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?
Module1
Public Function startprog()
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdate"
DoCmd.Quit acQuitSaveNone
End Function
Macro
AutoExec
(action) RUN CODE      
function name

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

Accepted Solution

by:
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
0
 
LVL 2

Assisted Solution

by:bartjoosen
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

Bart
0
 
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"
endif

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).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

895 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

21 Experts available now in Live!

Get 1:1 Help Now