Navigation:  DAO Object Classes > DaoRecordset Class >

DaoRecordset:Seek() Method

Previous pageReturn to chapter overviewNext page


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).



cCompareOne of the following string expressions: <, <=, =, >=, or >.
uKey1Up to 13 key values that have to match the corresponding fields in the
uKey2current index field list






You must set the current index with the Index property before you use Seek. If the index identifies a nonunique key field, Seek locates the first record that satisfies the criteria.


The Seek method searches through the specified key fields and locates the first record that satisfies the criteria specified by cCompare and cKey. Once found, it makes that record current and sets the NoMatch property to False. If the Seek method fails to locate a match, the NoMatch property is set to True, and the current record is undefined.


If cCompare is equal (=), greater than or equal (>=), or greater than (>), Seek starts at the beginning of the index and searches forward.

If cCompare is less than (<) or less than or equal (<=), Seek starts at the end of the index and searches backward. However, if there are duplicate index entries at the end of the index, Seek starts at an arbitrary entry among the duplicates and then searches backward.


You must specify values for all fields defined in the index. If you use Seek with a multiple-column index, and you don't specify a comparison value for every field in the index, then you cannot use the equal (=) operator in the comparison. That's because some of the cKey criteria fields will default to Null, which will probably not match. Therefore, the equal operator will work correctly only if you have a record which is all Null except the key you're looking for. It's recommended that you use the greater than or equal (>=) operator instead.


The uKey?? arguments must be of the same field data type as the corresponding field in the current index. For example, if the current index refers to a number field (such as Employee ID), uKey?? must be numeric.