LastModified Property Example (MDB)
The following example determines the most recently modified record in a recordset and sets a bookmark for that record:
Sub LastChangedRecord()
Dim dbs As Database, rst As Recordset, varBook As Variant
' Return reference to current database.
Set dbs = CurrentDb
' Create dynaset-type Recordset object.
Set rst = dbs.OpenRecordset("SELECT * " _
& "FROM Orders ORDER BY ShipCountry;")
With rst
.FindFirst "ShipCountry = 'UK'"
' Alter record and save changes.
.Edit
!ShipCountry = "USA"
.Update
End With
' Check to see if recordset supports bookmarks.
If rst.Bookmarkable Then
' Set bookmark to most recently modified record.
varBook = rst.LastModified
' Set currency to last modified record.
rst.Bookmark = varBook
End If
rst.Close
Set dbs = Nothing
End Sub