Home | Overview | How Do I | FAQ | Sample | Tutorial | ODBC Driver List
This article explains MFC's interfaces to:
For details about these properties in DAO, see the following topics in DAO Help:
Those DAO Help topics explain the fundamentals of the properties. This article explains how MFC exposes them to you.
Because records can be deleted from a recordset, you can't rely on the absolute position of a record within the recordset. The reliable way to keep track of the position of a particular record in your recordset is to use the record's bookmark.
Except for snapshot-type recordsets, each record has a unique bookmark from the time the recordset is created. In MFC, class CDaoRecordset supplies member functions for:
You can check whether a recordset supports bookmarks by calling CDaoRecordset::CanBookmark.
For example, suppose you want to mark the current record so you can later return to it easily. The following code does this:
// rs is a CDaoRecordset or
// CDaoRecordset-derived object
COleVariant varRecordToReturnTo;
varRecordToReturnTo = rs.GetBookmark( );
//...more code in which you move to other records
rs.SetBookMark( varRecordToReturnTo );
There is no need to extract the underlying data type from the COleVariant object. Simply get it with CDaoRecordset::GetBookmark and return to that bookmark with CDaoRecordset::SetBookmark.
Besides bookmarks (and Move, Seek, and Find), DAO provides two other ways to position the current record in a recordset: percent positioning and absolute positioning.
Note Neither absolute nor percent positioning is recommended for moving the current record to a specific record. Use a bookmark instead. See DAO Recordset: Bookmarks and Record Positions.
Neither percent positioning nor absolute positioning is available for table-type recordsets.
You can set the current record to a position that follows a specified percentage of the records in a recordset, and you can get the percentage position of the current record. This is useful for setting scroll bars. That is, you can:
Keep in mind the following guidelines:
For related information, see the topic "PercentPosition Property" in DAO Help.
You can set or get the record number of the current record in a recordset. That is, you can:
Important The absolute position of a record is potentially unreliable. If the user can delete records ahead of a position, the ordinal number of records following the deletion is decreased. Bookmarks are a more reliable method of working with record positions. See Bookmarks in MFC DAO.
Keep in mind the following guideline:
For related information, see the topic "AbsolutePosition Property" in DAO Help.
See Also DAO: Where Is..., DAO Recordset, DAO Recordset: Recordset Navigation, DAO Recordset: Seeking and Finding