DateCreated, LastUpdated Properties Example (MDB)
The following example enumerates through all QueryDef objects in the database and lists those which have been created or changed within the last sixty days:
Sub TimeUpdated()
Dim dbs As Database, tdf As TableDef, qdf As QueryDef
Dim strList As String, dtePast As Date
' Return reference to current database.
Set dbs = CurrentDb
dtePast = Date - 60
' Enumerate through QueryDefs collection.
For Each qdf In dbs.QueryDefs
' Evaluate LastUpdated and DateCreated properties.
If (qdf.LastUpdated > dtePast) Or (qdf.DateCreated > dtePast) Then
' Create list.
strList = strList & vbCrLf & qdf.Name
End If
Next qdf
MsgBox strList
Set dbs = Nothing
End Sub