CdbRecordset::FindFirst, FindLast, FindNext, FindPrevious Methods

Locates the first, last, next, or previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria, then makes that record the current record.

Syntax

VOIDFindFirst( LPCTSTRpstrCriteria);

VOIDFindLast( LPCTSTRpstrCriteria);

VOIDFindNext( LPCTSTRpstrCriteria);

VOIDFindPrevious( LPCTSTRpstrCriteria);

Parameters

Type Example Description
LPCTSTR pstrCriteria A pointer to a string expression (like the WHERE clause in an SQL statement without the word WHERE) used to locate the record.

Remarks

If you want to include all the records in your search, not just those that meet a specific condition, use the Move methods to move from record to record. To locate a record in a table-type Recordset, use the Seek method.

If a record matching the criteria isn't located, the current record pointer is undetermined, and the NoMatch property is set to TRUE. If the Recordset contains more than one record that satisfies the criteria, FindFirst locates the first occurrence, FindNext locates the next occurrence, and so on.

Usage

#include <afxole.h>
#include <dbdao.h>
...
CdbBookmark      bmHere;
CdbRecordset      rstCustomers;
...
// Save current record position.
bmHere = rstCustomers.GetBookmark();   
// Search for a name in the recordset.
rstCustomers.FindFirst(_T("Name = 'Ms. Schmidt'"));
// If not found go back to saved record position.
if (rstCustomers.GetNoMatch()) 
   rstCustomers.SetBookmark( &bmHere );