Recordset.FindFirst / FindLast / FindNext / FindPrevious

Find records within a recordset.

Syntax
      expression.FindFirst(Criteria)

      expression.FindLast(Criteria)

      expression.FindNext(Criteria)

      expression.FindPrevious(Criteria)

Key
   Criteria   A String used to locate the record.
              Like the WHERE clause in an SQL statement,
              but without the word WHERE.

The Find methods locate a record in a dynaset- or snapshot-type Recordset object that satisfy the specified criteria and make that record the current record.

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

You can follow a Find operation with a Move operation.

Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If the search succeeds, NoMatch is False. If it fails, NoMatch is True and the current record isn't defined. In this case, you must position the current record pointer back to a valid record.

Using the Find methods with an ODBC-accessed recordsets can be inefficient. You may find that rephrasing your criteria to locate a specific record is faster, especially when working with large recordsets.

To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.

Use the U.S. date format (month-day-year) when searching for fields containing dates

Example

rstPatients.FindFirst "AdmissionDate > #" & Format(Me!txtAdmission, 'm-d-yy' ) & "#"

“A bad beginning makes a bad ending” ~ Euripides

Related:

MoveFirst/Last/Next/Previous Record
.Move - Move through a Recordset
RecordSet.Close - Close a recordset
Update - Save a recordset
CancelUpdate - Cancel recordset changes


© Copyright SS64.com 1999-2013
Some rights reserved