Solved

using autoexec macro and windows scheduled task to run queries

Posted on 2010-08-20
3
598 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

860 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