편집

다음을 통해 공유


DoCmd.FindRecord method (Access)

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 An AcFindMatch constant that specifies where to search for the match. The default 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 An AcFindField constant that specifies whether 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 specified 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.

DoCmd.FindRecord "Smith",, True,, True

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.