You can use the FindRecord action to find the first record following the current record that meets the criteria specified by the FindRecord action arguments. You can find records in the active table datasheet, query datasheet, form datasheet, or form.
The FindRecord action uses the following arguments.
Action argument |
Description |
Find What |
Specifies the data you want to find in the record. Enter the text, number, or date you want to find or type an expression, which is preceded by an equal sign (=). You can use wildcard characters. This is a required argument. |
Action argument |
Description |
Match |
Specifies where the data is located in the field. You can specify a search for data in any part of the field (Any Part Of Field), for data that fills the entire field (Whole Field), or for data located at the beginning of the field (Start Of Field). The default is Whole Field. |
Match Case |
Specifies whether the search is case-sensitive (uppercase and lowercase letters must match exactly). Click Yes to conduct a case-sensitive search or No to search without matching uppercase and lowercase letters exactly. The default is No. |
Search |
Specifies whether the search proceeds from the current record up to the beginning of the records (Up); down to the end of the records (Down); or down to the end of the records and then from the beginning of the records to the current record, so all records are searched (All). The default is All. |
Search As Formatted |
Specifies whether the search includes formatted data. If you click Yes, Microsoft Access searches for the data as it is formatted and displayed in the field. If you click No, Microsoft Access searches for the data as it is stored in the database, which is not always the same as it is displayed. The default is No. |
You can use this feature to restrict the search to data in a particular format. For example, click Yes and enter 1,234 in the Find What argument to find a value of 1,234 in a field formatted to include commas. Click No if you want to enter 1234 to search for the data in this field. | |
To search for dates, click Yes to find a date exactly as it is formatted, such as 03-March-1991. If you click No, enter the date in the Find What argument in the format set in the Regional Settings Properties dialog box in the Microsoft Windows Control Panel. (This is the Short Date style found on the Date tab of the Regional Settings Properties dialog box.) For example, if the Short Date style format is set to M/d/yy, you can enter 3/9/91, and Microsoft Access will find all entries in a Date field that correspond to March 9, 1991, regardless of how this field is formatted. | |
Note Note This argument takes effect only if the current field is a bound control, the Match argument is set to Whole Field, the Only Current Field argument is set to Yes, and the Match Case argument is set to No.
If you set Match Case to Yes or Only Current Field to No, you must also set Search As Formatted to Yes. | |
Action argument |
Description |
Only Current Field |
Specifies whether the search is confined to the current field in each record or includes all fields in each record. The current field search is faster. Click Yes to confine the search to the current field or No to search in all fields in each record. The default is Yes. |
Find First |
Specifies whether the search starts at the first record or at the current record. Click Yes to start at the first record. Click No to start at the current record. The default is Yes. |
When a macro runs the FindRecord action, Microsoft Access moves to the next record containing the specified data and selects the data in the record.
The FindRecord action is equivalent to clicking Find on the Edit menu, and its arguments are the same as the options in the Find In Field dialog box. If you set the FindRecord action arguments in the Macro window and then run the macro, you’ll see the corresponding options selected in the Find In Field dialog box when you click Find.
Microsoft Access retains the most recent FindRecord arguments during a database session so that you don’t need to enter the same criteria repeatedly as you perform subsequent FindRecord operations. If you leave an argument blank, Microsoft Access uses the most recent setting for the argument, as set either by a previous FindRecord action or in the Find In Field dialog box.
When you want to find a record using a macro, use the FindRecord action, not the DoMenuItem action with arguments set to run the Find command.
Note While the FindRecord action corresponds to Find on the Edit menu for tables, queries, and forms, it does not correspond to Find on the Edit menu in the Module window. You can’t use the FindRecord action to search for text in modules.
To run the FindRecord action in Visual Basic, use the FindRecord method of the DoCmd object.
FindNext Action, FindRecord Method.