Search for a specific record (Access 2007+).

      DoCmd.SearchForRecord(ObjectType, ObjectName,
                            Record, WhereCondition)

   ObjectType  An AcDataObjectType constant that specifies
               the type of database object to search.
               default = acActiveDataObject.

   ObjectName  The database object that contains the record
               to search for.

   Record      An AcRecord constant that specifies the 
               starting point and direction of the search.
               default = acFirst.

               A string used to locate the record.
               Like a WHERE clause in an SQL statement,
               but without the word WHERE.

The object specified in the ObjectName argument must be open before this action is run. Otherwise, an error occurs.

If the criteria in the WhereCondition argument are not met, the focus will remain on the current record.

The SearchForRecord method is similar to the FindRecord method, but SearchForRecord has more powerful search features. SearchForRecord supports logical operators, such as <, >, AND, OR, and BETWEEN. The FindRecord method only matches strings that equal, start with, or contain the string being searched for.


'Find the first matching Order:
DoCmd.SearchForRecord acDataForm, "frmOrders", acFirst, "[OrderID] = " & Me!txtOrderID

“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


GoToRecord - Move to a specific record in a dataset.

Copyright © 1999-2024
Some rights reserved