Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating Queries to Run at Specific Time

Status
Not open for further replies.

deepgrewal22

Instructor
May 2, 2005
108
Is there anyway that I can have a group of queries automatically run at a specific time during the day or at a specific time on specific days only?

Deep Gréwal
Don't say the M word; you sound ignorant.
 
I have created a database that houses the queries (and necessary tables) with a form to use for startup. Code in the on open of the form deteremines the day and time which then determines which query to run.

The other piece is windows scheduler. It open the database at the time and day(s) it is told. I made a different schedule for each query. A macro could be used as well if there are multiple queries to run or just use docmd.xxx
 
Thanks. That made me actually read the code and realize I left a part out. Sorry. First- the code:
Private Sub Form_Open(Cancel As Integer)
Select Case Format(Date, "dddd")
Case "Tuesday"
Select Case Format(Now, "h")
Case Is < 3
DoCmd.OpenForm "frmSpring"
Case Is < 9
DoCmd.OpenForm "frmFall"
Case Is < 17
DoCmd.OpenForm "frmWinter"
End Select
Case "Wednesday"
Select Case Format(Now, "h")
Case Is < 3
DoCmd.OpenForm "frmFord"
Case Is < 9
DoCmd.OpenForm "frmChevy"
Case Is < 17
DoCmd.OpenForm "frmBicycle"
End Select
Case "Friday"
Select Case Format(Now, "h")
Case Is < 3
DoCmd.OpenForm "frmSales"
Case Is < 9
DoCmd.OpenForm "frmArrival"
Case Is < 17
DoCmd.OpenForm "frmDeparture"
End Select

Case Else
Select Case Format(Now, "h")
Case Is < 3
DoCmd.OpenForm "frmMarksDat"
Case Else
DoCmd.OpenForm "frmKarensData"
End Select

End Select
End Sub



1 Main form. This form determines the time and date as the code above shows,

The part I omitted was a form, blank, with an on open event that runs the query. Each quesry has it's on code. Doesn't have to...since it knows the time and date, it can docmd.openquery....or whatever. My forms have much more behind them than a one liner so I made different forms.
 
Zygor,

Thanx that worked like a charm in the Test environment. Production environment should not be a problem.

Deep Grewal
Don't say the M word (Microsoft); you sound ignorant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top