Dela via


CDaoRecordset::Find

Call this member function to locate a particular string in a dynaset- or snapshot-type recordset using a comparison operator.

virtual BOOL Find(
   long lFindType,
   LPCTSTR lpszFilter 
);

Parameters

  • lFindType
    A value indicating the type of Find operation desired. The possible values are:

    • AFX_DAO_NEXT   Find the next location of a matching string.

    • AFX_DAO_PREV   Find the previous location of a matching string.

    • AFX_DAO_FIRST   Find the first location of a matching string.

    • AFX_DAO_LAST   Find the last location of a matching string.

  • lpszFilter
    A string expression (like the WHERE clause in a SQL statement without the word WHERE) used to locate the record. For example:

    rs.Find(AFX_DAO_FIRST, _T("EmployeeID = 7"));
    rs.Find(AFX_DAO_NEXT, _T("LastName = 'Jones'"));
    

Return Value

Nonzero if matching records are found, otherwise 0.

Remarks

You can find the first, next, previous, or last instance of the string. Find is a virtual function, so you can override it and add your own implementation. The FindFirst, FindLast, FindNext, and FindPrev member functions call the Find member function, so you can use Find to control the behavior of all Find operations.

To locate a record in a table-type recordset, call the Seek member function.

Tip

The smaller the set of records you have, the more effective Find will be. In general, and especially with ODBC data, it is better to create a new query that retrieves just the records you want.

For related information, see the topic "FindFirst, FindLast, FindNext, FindPrevious Methods" in DAO Help.

Requirements

Header: afxdao.h

See Also

Reference

CDaoRecordset Class

Hierarchy Chart

CDaoRecordset::FindFirst

CDaoRecordset::FindLast

CDaoRecordset::FindNext

CDaoRecordset::FindPrev

Other Resources

CDaoRecordset Members