Ave
I won't write the code for ya, but I am happy to give you a little
direction to get this done.
Create a Table (tblRunQuery) with one Column (NextRun) as a Date/Time
field. Open the table and in the New Row enter a date like 5/12/2004
11:00Pm Close the table
Create a new form (frmRunQuery)
In the Forms TimerInterval Property enter 60000
Create an Event Procedure for the InTimer Property
Next you need to write some VBA for the Event Property. The Code it
Might look like:
Private Sub Form_Timer()
Dim dteNextRun as Date, strSql as String
dteNextRun = Dlookup("NextRun","tblRunNext")
if Now() > dteNextRun then
' Your code to run the query
' yada-yada-yada
' Next we need some code to re-Schedule our NextRun to same
time
tomorrow.
strSql = "Update tblRunQuery Set NextRun =
DateAdd('d',1,[NextRun])" docmd.SetWarnings false
docmd.RunSql strSql
docmd.SetWarnings true
end if
end sub
Basically what you have created is a form with No interface, that once
a minute looks to see if it is time to run the query. If it isn't
time yet it does nothing. When the time has come to run the query it
does so and then sets the NextRun to one day after the current value.
So if you set the initial value to 5/12/2004 11:00pm it will reset the
NextRun time to 5/13/2004 11:00pm when it executes.
Now that said this is just a skeleton of what you need to do as this
routing has NO ERROR Trapping at all. You also may want to create a
log of the Query start and stop times and any other events you are
interested in so you can have a history that the job did in fact run.
Anyway there's my 2 cents, don't spend it all in one place.
Ron W
ave said:
I would like to have access open and run a specified query at 11:00
PM each
night
How would i write the timer code to do this?
thanks in advance