Article ID: 125772
Article Last Modified on 1/19/2007
Form: Batch Process Form
----------------------------------
Text box:
Name: Current Time
ControlSource: =Now()
Command button:
Name: Initiate Batch Processes
Caption: Run
Private Sub Initiate_Batch_Processes_Click()
MsgBox (Now)
MsgBox ("Use CTRL+BREAK to terminate manually.")
On Error Resume Next
'***************************************************************
' "On Error Resume Next" allows processing to continue if, for
' example, Table1 does not exist when the code tries to delete
' it. The code would then delete the other three tables and
' create four new tables. If you want to know when errors such
' as this occur, you must add more error-trapping code.
'***************************************************************
Do
DoEvents
Loop Until Now > CVDate(Date & " 11:00:00 PM")
'***************************************************************
' Change the time to the time you want processing to begin. For
' example,
' Loop Until Now > "10/4/94 11:55:00 PM"
' -or-
' Loop Until Now > "10/5/94 12:05:00 AM"
' NOTE: Do not use leading zeros in dates. Use
' 10/4/94 11:55:00 PM
' but not
' 10/04/94 11:55:00 PM
' Leading zeros are optional in the time portion of the string.
' "AM" and "PM" are not case sensitive.
' Double-check the dates you enter, and make sure you have used
' "AM" and "PM" correctly. Each entry should have only two spaces
' (one between the date and the time, and the other between the
' time and "AM" or "PM"). If you get stuck in a loop, use
' CTRL+BREAK and then reset your code to start a new test. You
' can also use Control Panel's Date/Time icon to reset the
' computer's time.
NOTE: the following code is divided into two sections: one for
versions 7.0 and 97, and the other for versions 1.x and 2.0.
Application.SetOption "Confirm Action Queries", 0
DoCmd.DeleteObject A_TABLE, "Table1"
DoCmd.OpenQuery "Query1"
Do
DoEvents
Loop Until Now > CVDate(Date & " 4:00:00 AM")
DoCmd.DeleteObject A_TABLE, "Table2"
DoCmd.OpenQuery "Query2"
MsgBox ("Timed processes completed.")
Application.SetOption "Confirm Action Queries", -1
End Sub
In Microsoft Access 1.x and 2.0 type:
Application.SetOption "Confirm Action Queries", 0
DoCmd DeleteObject A_TABLE, "Table1"
DoCmd OpenQuery "Query1"
Do
DoEvents
Loop Until Now > CVDate(Date & " 4:00:00 AM")
DoCmd DeleteObject A_TABLE, "Table2"
DoCmd OpenQuery "Query2"
MsgBox ("Timed processes completed.")
Application.SetOption "Confirm Action Queries", -1
End Sub
Sample Overnight Decision Flowchart:
Do critical daily activity processes needed by tomorrow or ASAP
(backups, accounts receivable, patient status, and so on).
If critical processes fail? THEN
Call or page primary responsible person or
secondary responsible person or management.
If some or all critical processes continue to fail
or help is slow in arriving? THEN
Run processes not dependent on previous failures.
Else
Continue to analyze the problem and wait for help.
Else
Do any remaining daily activity updates.
Do nightly backups after updating. (It is your business
decision whether to back up your data before or after nightly
processing, or both before and after.)
Do reporting.
Do user-specific batch SQL requests.
Upon returning, check status of processes.Additional query words: archive
Keywords: kbinfo kbprogramming KB125772