AbsolutePosition Property Example
This example uses the AbsolutePosition property to track the progress of a loop that enumerates all the records of a Recordset.
Sub AbsolutePositionX()
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Dim strMessage As String
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' AbsolutePosition only works with dynasets or snapshots.
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees", _
dbOpenSnapshot)
With rstEmployees
' Populate Recordset.
.MoveLast
.MoveFirst
' Enumerate Recordset.
Do While Not .EOF
' Display current record information. Add 1 to
' AbsolutePosition value because it is zero-based.
strMessage = "Employee: " & !LastName & vbCr & _
"(record " & (.AbsolutePosition + 1) & _
" of " & .RecordCount & ")"
If MsgBox(strMessage, vbOKCancel) = vbCancel _
Then Exit Do
.MoveNext
Loop
.Close
End With
dbsNorthwind.Close
End Sub