DoCmd.FindRecord (Access)

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

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.

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


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

Arguments

The following argument is required

FindWhat - An expression that evaluates to text, a number, or a date. The expression contains the data to search for

Optional arguments

The following arguments are optional

Match (AcFindMatch) - An AcFindMatch constant that specifies where to search for the match. The default value is acEntire.

Possible return values are acAnywhere - Search for data in any part of the field, acEntire - Search for data that fills the entire field, acStart - Search for data located at the beginning of the field.

MatchCase (Boolean) - 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 (AcSearchDirection) - An AcSearchDirection constant that specifies the direction to search. The default value is acSearchAll.

Possible return values are acDown - Search all records below the current record, acSearchAll - Search all records, acUp - Search all records above the current record.

SearchAsFormatted (Boolean) - 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 (AcFindField) - An AcFindField constant that specifies whether to search all fields, or only the current field. The default value is acCurrent.

Possible return values are acAll - Search in all fields in each record, acCurrent - Confine the search to the current field.

FindFirst (Boolean) - 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.