Automatically Run an access query at a specified time

Is there a way to set a query or VBA module to run automatically at a certain time each day?
jrimmeleAsked:
Who is Participating?
 
rockiroadsConnect With a Mentor Commented:
ok, found this. Perhaps this may help

u can use windows task scheduler to start pc, but that pc has to be in hibernate/standby mode
http://www.pcworld.com/howto/article/0,aid,124169,00.asp

so one task to start pc
one to run app - which when finishes running, shutsdown pc


if u do all this, I suggest u add logging so u know whether it worked or not
0
 
rockiroadsCommented:
u could use the windows task scheduler to run a VBa macro

u can pass in parameters like /x macroname in access

alternatively u can create a macro called AutoExec
this will run your code/query then exit the DB
0
 
rockiroadsCommented:
here are the switches for msacess

http://support.microsoft.com/?kbid=209207


as you can see u pass in

/x macroname into msaccess.exe (note full path of msaccess.exe will have to be specified)

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jjafferrCommented:
Hi jrimmele,

you will have to have a Form that is open at the time when you want this to happen,
I usually have the main Form always open, and you can make the Time interval of the Form to 1 minute (which is 1000 x 60),
and have the following code "On Timer" of the Form

Private Sub Form_Timer()
    Dim TheTime As Date
    TheTime = Format(Now(), "hh:mm")

    Select Case TheTime
        Case #10:30:00 PM#
            DoCmd.openquery "your query name"
    Case Else
            'do nothing
    End Select

End Sub


jaffer
0
 
jrimmeleAuthor Commented:
I was able to get it to work through the task scheduler.  What I was really hoping for was to be able to do was to run the process in the middle of the night sometime, but it doesn't seem to work unless the PC is on - is there a way to get the task to run even if the computer is not on?
0
 
rockiroadsCommented:
urm, no.
if the computer is on, then no programs run

You have to leave it on. I guess what u could add is some code that shuts down the PC after it runs your job
here is an example

http://www.mvps.org/access/api/api0016.htm

0
 
rockiroadsCommented:
urm, typo

if the computer is NOT on, then no programs run

0
All Courses

From novice to tech pro — start learning today.