Share via


DoCmd.FindRecord Method

Access Developer Reference

The FindRecord method carries out the FindRecord action in Visual Basic.

Syntax

expression.FindRecord(FindWhat, Match, MatchCase, Search, SearchAsFormatted, OnlyCurrentField, FindFirst)

expression   A variable that represents a DoCmd object.

Parameters

Name Required/Optional Data Type Description
FindWhat Required Variant An expression that evaluates to text, a number, or a date. The expression contains the data to search for.
Match Optional AcFindMatch A AcFindMatch constant that specifies where to search for the match. The dcefault value is acEntire.
MatchCase Optional Variant Use True for a case-sensitive search and False for a search that's not case-sensitive. If you leave this argument blank, the default (False) is assumed.
Search Optional AcSearchDirection an AcSearchDirection constant that specifies the direction to search. The default value is acSearchAll.
SearchAsFormatted Optional Variant Use True to search for data as it's formatted and False to search for data as it's stored in the database. If you leave this argument blank, the default (False) is assumed.
OnlyCurrentField Optional AcFindField A AcFindField constant that specifies whther to search all fields, or only the current field. The default value is acCurrent.
FindFirst Optional Variant Use True to start the search at the first record. Use False to start the search at the record following the current record. If you leave this argument blank, the default (True) is assumed.

Remarks

When a procedure calls the FindRecord method, Access searches for the specified data in the records (the order of the search is determined by the setting of the Search argument). When Access finds the specified data, the data is selected in the record.

The FindRecord method does not return a value indicating its success or failure. To determine whether a value exists in a recordset, use the FindFirst, FindNext, FindPrevious or FindLast method of the Recordset object. These methods set the value of the NoMatch property to True if the spcified value is not found.

Example

The following example finds the first occurrence in the records of the name Smith in the current field. It doesn't find occurrences of smith or Smithson.

Visual Basic for Applications
  DoCmd.FindRecord "Smith",, True,, True