Sun
ONE Active Server Pages Product Home Page Developer Site Version
 

ContentsPreviousNextIndex



ADO Recordset Object AbsolutePosition Property

Specifies the ordinal position of a Recordset object's current record.

AbsolutePosition Property Return Values

Sets or returns a Long value from 1 to the number of records in the Recordset object (RecordCount), or returns one of the following constants:

Constant
Description
adPosUnknown
The recordset is empty, the current position is unknown, or the provider does not support the AbsolutePosition property.
adPosBOF
The current record pointer is at BOF (that is, the BOF property is True).
adPosEOF
The current record pointer is at EOF (that is, the EOF property is True).

AbsolutePosition Property Remarks

Use the AbsolutePosition property to move to a record based on its ordinal position in the Recordset object, or to determine the ordinal position of the current record. The provider must support the appropriate functionality for this property to be available.

Like the AbsolutePage property, AbsolutePosition is 1-based and equals 1 when the current record is the first record in the recordset. You can obtain the total number of records in the Recordset object from the RecordCount property.

When you set the AbsolutePosition property, even if it is to a record in the current cache, ADO reloads the cache with a new group of records starting with the record you specified. The ADO Recordset Object CacheSize Property determines the size of this group.

Note icon Note You should not use the AbsolutePosition property as a surrogate record number. The position of a given record changes when you delete a preceding record. There is also no assurance that a given record will have the same AbsolutePosition if the Recordset object is requeried or reopened. Bookmarks are still the recommended way of retaining and returning to a given position, and are the only way of positioning across all types of Recordset objects.
AbsolutePosition Property Example

This Visual Basic example demonstrates how the AbsolutePosition property can track the progress of a loop that enumerates all the records of a recordset. It uses the CursorLocation property to enable the AbsolutePosition property by setting the cursor to a client cursor.

Public Sub AbsolutePositionX() 
Dim rstEmployees As ADODB.Recordset 
Dim strCnn As String 
Dim strMessage As String
' Open a recordset for the Employee table 
' using a client cursor. 
strCnn = "driver={SQL Server};server=srv;" & _ 
"uid=sa;pwd=;database=pubs" 
Set rstEmployees = New ADODB.Recordset
' Use client cursor to enable AbsolutePosition property. 
rstEmployees.CursorLocation = adUseClient 
rstEmployees.Open "employee", strCnn, , , adCmdTable 
' Enumerate Recordset. 
Do While Not rstEmployees.EOF
' Display current record information. 
strMessage = "Employee: " & rstEmployees!lName & vbCr & _ 
"(record " & rstEmployees.AbsolutePosition & _ 
" of " & rstEmployees.RecordCount & ")" 
If MsgBox(strMessage, vbOKCancel) = vbCancel _ 
Then Exit Do 
rstEmployees.MoveNext 
Loop 
rstEmployees.Close 
End Sub


ContentsPreviousNextIndex