>
LastModified Property
Applies To
Dynaset-Type Recordset Object, Recordset Object, Table-Type Recordset Object.
Description
Returns a bookmark indicating the most recently added or changed record.
Return Values
The return value is a Variant array of Byte data.
Remarks
You can use LastModified property to move to the most recently added or updated record. Use the LastModified property with Recordset objects. A record must be modified in the Recordset object itself in order for LastModified property to have a value.
See Also
Bookmark Property; Bookmarkable Property; DateCreated, LastUpdated Properties.
Specifics (Microsoft Access)
When you use the LastModified property in a Microsoft Access module, you must include an Option Compare Binary statement in the Declarations section of the module. The bookmark returned by the LastModified property is a Variant array of Byte data, so the string comparison method for the module must be binary. If a bookmark is evaluated with a text-based string comparison method, such as the Option Compare Text statement or the default setting for the Option Compare Database statement, the current record may be set to an incorrect record.
Example
See the AddNew method example.
Example (Microsoft Access)
The following example prints the value of the OrderDate field for the most recently modified record in a recordset.
' Include this statement in the Declarations section of the module.
Option Compare Binary
Sub LastChangedRecord()
Dim dbs As Database, rst As Recordset, varBook As Variant
' Return Database variable that points to current database.
Set dbs = CurrentDb
' Create Dynaset-Type Recordset object.
Set rst = dbs.OpenRecordset("SELECT * FROM Orders " & _
"ORDER BY [ShipCountry]")
With rst
' Populate recordset.
.MoveLast
' Move to first record and search.
.MoveFirst
.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
' Display changed value.
Debug.Print rst.Fields!ShipCountry
End If
End Sub