DoCmd.FindRecord

Find a record.

Syntax
      DoCmd.FindRecord(FindWhat, Match, MatchCase, Search,
                 SearchAsFormatted, OnlyCurrentField, FindFirst)
Key
   FindWhat  The data to search for. 
             A text, number or date expression. 

   Match     Where in the field to search for the match.
             acAnywhere (0), acEntire (1), acStart (2)

   MatchCase Use True for a case-sensitive search
             or False for non case-sensitive.

   Search    The direction to search.
             acUp (0), acDown (1), acSearchAll (2)

   SearchAsFormatted
             Use True to search for data as it's formatted
             or False to search for data as it's stored in the database. 

   OnlyCurrentField
             Search all fields, or only the current field.
             acAll (0), acCurrent (-1)

   FindFirst Use True to start the search at the first record.
             or False to start the search at the record following the current record.

FindRecord searches for the specified data in the records, if found, the data is selected in the record.

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

Example

'Find the first occurrence of the name Smith in the surname field. (not 'smith' or 'Smithson').
Me!txtSurname.SetFocus
DoCmd.FindRecord "Smith",, True,, True

“Twenty years from now, you will be more disappointed by the things you didn't do than by the ones you did do. So throw off the bowlines, sail away from the safe harbour. Catch the trade winds in your sails. Explore. Dream. Discover” ~ Mark Twain

Related:

SearchForRecord - Search for a specific record.
MoveFirst/Last/Next/Previous Record
.Move - Move through a Recordset


© Copyright SS64.com 1999-2014
Some rights reserved