bocjoel said:
Is there a way to record and/or view the last time a query was executed
(without being modified)? I have a query being executed from a Form and
would like to monitor its usage.
There's nothing that will do that automatically. However,
you can create a custom property on the QueryDef object and
use a function to save a date/time value. Then your form's
code can run the query and set the property, e.g.
db.Execute "youractionquery"
SetQDefProp "youractionquery", "LastUsed", Now
Here's the procedure that deals with the QuerDef property:
Public Sub SetQDefProp(qname As String, _
propname As String, propval As Variant)
Dim db As DAO.Database
Dim qdf As QueryDef
Dim prp As Property
On Error GoTo ErrHandler
Set db = CurrentDb()
Set qdf = db.QueryDefs(qname)
qdf.Properties(propname) = propval
ExitHere:
Set qdf = Nothing
Set db = Nothing
Exit Sub
ErrHandler:
Select Case Err.number
Case 3270
Set prp = qdf.CreateProperty(propname, _
dbDate, propval)
qdf.Properties.Append prp
Set prp = Nothing
Case Else
MsgBox Err.number & "-" & Err.Description
End Select
Resume ExitHere
End Sub