Here is a small routine that should do what you want. I suggest you test it to ensure it does what it is suppose to. I am using Acc2003. You can test the records in tblQueryLogger to determine when a query was executed.
This requires that you create a table in your local database:
' I created a table tblQueryLogger, with fields
' id autonumber PK
' RunTimeStamp Date/Time
' QueryName text
'
' This table must exist before you run the procedure.
You will have to enter the real names of your queries into the array QNames. See the comments in the module code.
This is a one time set up
Code:
'---------------------------------------------------------------------------------------
' Procedure : ExecuteQueriesAndLogInfo
' Author : Jack
' Date : 20-06-2012
' Purpose :To run 3 make table queries and log their run date and time
'to tblQueryLogger
'
' I created a table tblQueryLogger, with fields
' id autonumber PK
' RunTimeStamp Date/Time
' QueryName text
'
' This table must exist before you run the procedure.
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: N/A
'--------------------------------------------------------------------------
'
Sub ExecuteQueriesAndLogInfo()
Dim db As DAO.Database
Dim queryLog As DAO.Recordset
Dim qNames(2) As String 'array to hold the 3 query names
Dim i As Integer
On Error GoTo ExecuteQueriesAndLogInfo_Error
qNames(0) = "yourfirstMTqueryname"
qNames(1) = "your2ndMTqueryname"
qNames(2) = "your3rdMTqueryname"
Set db = CurrentDb
Set queryLog = db.OpenRecordset("tblQueryLogger")
Debug.Print vbCrLf & vbCrLf & Now & " Starting query runs " & vbCrLf
For i = 0 To 2
queryLog.AddNew
queryLog!queryName = qNames(i)
queryLog!runTimeStamp = Now
Debug.Print qNames(i) & ".... " & Now 'for debugging
db.Execute qNames(i), dbFailOnError 'This runs the MT query with qnames(i)
queryLog.Update
Next i
queryLog.Close
On Error GoTo 0
Exit Sub
ExecuteQueriesAndLogInfo_Error:
MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure ExecuteQueriesAndLogInfo"
End Sub