CDaoRecordset::SetAbsolutePosition

void SetAbsolutePosition( long lPosition );
throw( CDaoException, CMemoryException );

Parameters

lPosition

Corresponds to the ordinal position of the current record in the recordset.

Remarks

Sets the relative record number of a recordset object’s current record. Calling SetAbsolutePosition enables you to position the current record pointer to a specific record based on its ordinal position in a dynaset-type or snapshot-type recordset. You can also determine the current record number by calling GetAbsolutePosition.

Note   This member function is valid only for dynaset-type and snapshot-type recordsets.

The AbsolutePosition property value of the underlying DAO object is zero-based; a setting of 0 refers to the first record in the recordset. Setting a value greater than the number of populated records causes MFC to throw an exception. You can determine the number of populated records in the recordset by calling the GetRecordCount member function.

If the current record is deleted, the AbsolutePosition property value is not defined, and MFC throws an exception if it is referenced. New records are added to the end of the sequence.

Note   This property is not intended to be used as a surrogate record number. Bookmarks are still the recommended way of retaining and returning to a given position and are the only way to position the current record across all types of recordset objects that support bookmarks. In particular, the position of a given record changes when record(s) preceding it are deleted. There is also no assurance that a given record will have the same absolute position if the recordset is re-created again because the order of individual records within a recordset is not guaranteed unless it is created with an SQL statement using an ORDER BY clause.

For more information about finding records, see the article DAO Recordset: Recordset Navigation in Visual C++ Programmer's Guide. For related information, see the topic "AbsolutePosition Property" in DAO Help.

CDaoRecordset OverviewClass MembersHierarchy Chart

See Also   CDaoRecordset::GetAbsolutePosition