>

DateCreated, LastUpdated Properties

Applies To

Document Object, QueryDef Object, Recordset Object, Table-Type Recordset Object, TableDef Object.

Return Values

This property returns a Date/Time data type.

Remarks

You can use the DateCreated and LastUpdated properties with Recordset, TableDef, QueryDef, and Document objects.

For table-type Recordset objects, the date and time settings are derived from the computer on which the base table was created or last updated. For other objects, this property returns the date and time that the object was created or last updated. In a multiuser environment, users should get these settings directly from the file server to avoid discrepancies in the DateCreated and LastUpdated property settings.

Example

This example determines the date and time when the Employees table was created and last updated.


Dim varCreation As Variant, varDesignChange As Variant
Dim rstEmployees As Recordset, dbsNorthwind As Database
Set dbsNorthwind = DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
Set rstEmployees = dbsNorthwind.OpenRecordset("Employees", dbOpenTable)
varCreation = rstEmployees.DateCreated
varDesignChange = rstEmployees.LastUpdated
Example (Microsoft Access)

The following example enumerates through all QueryDef objects in the database and lists those which have been created or changed within the last week.


Sub TimeUpdated()
    Dim dbs As Database, tdf As TableDef, qdf As QueryDef
    Dim strList As String, intI As Integer
    Dim dteWeek As Date

    ' Return Database variable that points to current database.
    Set dbs = CurrentDb
    dteWeek = Now - 7
     intI = 0
    ' Enumerate through QueryDefs collection.
    For Each qdf In dbs.QueryDefs
        ' Evaluate LastUpdated and DateCreated properties.
        If (qdf.LastUpdated > dteWeek) Or (qdf.DateCreated > dteWeek) _             Then
            ' Create list.

            strList = strList & Chr(13) & Chr(10) & qdf.Name
        End If
        intI = intI + 1
    Next qdf
    MsgBox strList
End Sub
Example (Microsoft Excel)

This example displays the dates and times when the Customer recordset in the NWINDEX.MDB database was created and last updated.

To create the NWINDEX.MDB database, run the Microsoft Excel example for the CreateDatabase method.


Dim creation As Variant, changed As Variant
Dim db As Database, td As TableDef
Set db = Workspaces(0).OpenDatabase(Application.Path & "\NWINDEX.MDB")
Set td = db.TableDefs("Customer")
creation = td.DateCreated
changed = td.LastUpdated
MsgBox "The " & td.Name & " table was created on " & creation _
    & " and updated on " & changed
db.Close