FindNext Macro Action

You can use the FindNext action to find the next record that meets the criteria specified by the previous FindRecord action or the value in the Find and Replace dialog box (on the Home tab, click Find). You can use the FindNext action to search repeatedly for records. For example, you can move successively through all the records for a specific customer.

Setting

The FindNext action doesn't have any arguments. The FindNext action finds the next record that meets the criteria set either by the FindRecord action or in the Find and Replace dialog box. The arguments for the FindRecord action are shared with the options in the Find and Replace dialog box.

To set the search criteria, use the FindRecord action. Typically, you enter a FindRecord action in a macro and then use the FindNext action to find succeeding records that meet the same criteria. To search for records only when a certain condition is met, you can enter a conditional expression in the Condition column of the action row for the FindNext action.

Remarks

This action has the same effect as using the Find Next button in the Find and Replace dialog box.

** Note **  Although the FindRecord action corresponds to the Find command on the Home tab for tables, queries, and forms, it doesn't correspond to the Find command on the Edit menu in the Code window. You can't use the FindRecord action or FindNext action to search for text in modules.

Tip

If you've set the Only Current Field argument of the FindRecord action to Yes, you may need to use the GoToControl action to move the focus to the control containing the data you're searching for before you use the FindNext action.

If the currently selected text is the same as the search text at the time the FindNext macro action is carried out, the search begins immediately following the selection, in the same field as the selection, and in the same record. Otherwise, the search begins at the start of the current record. This enables you to find multiple instances of the same search criteria that might appear in a single record.

However, note that if you use a command button to run a macro containing the FindNext action, the first instance of the search criteria will be found repeatedly. This behavior occurs because clicking the command button removes the focus from the field containing the matching value. The FindNext action will then begin searching from the start of the record. To avoid this problem, run the macro by using a technique that doesn't change the focus, such as a custom toolbar button or a key combination defined in an AutoKeys macro. Alternatively, set the focus in the macro to the field containing the search criteria before you carry out the FindNext action.

The same behavior also occurs if you use a command button to run a macro containing the FindRecord action with the Find First argument set to No.

To run the FindNext action in a Visual Basic for Applications module, use the FindNext method of the DoCmd object.