CdbRecordset::Seek Method

Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Jet workspaces only).

Syntax

VOIDSeek(LPCTSTR pstrComparison,

LONG lNumFields,

COleVariant cKey,

...);

Parameters

Type Example Description
LPCTSTR pstrComparison One of the following string expressions: <, <=, =, >=, or >.
LONG lNumFields The number of key arguments that follow. This argument may have a value from 1 to 13. (The maximum value of this parameter is defined by DAO_MAXSEEKFIELDS.)
COleVariant cKey, ... One or more values corresponding to fields in the Recordset object's current index, as specified by its Index property setting. Seek accepts an unspecified number of arguments, as indicated by the ellipsis symbol ("..."), however you may only have a maximum of 13 key arguments.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbDBEngine      dben;
CdbDatabase      dbs;
CdbRecordset      rst;
...
   // Open a table-type recordset.
rst = dbs.OpenRecordset(..., dbOpenTable);
   // Define current index as the LastName index.
rst.SetIndex(_T("LastName"));
   // Seek first record with last name equal to Smith
rst.Seek("=", 1, _T("Smith"));