GoToControl Action

Description

You can use the GoToControl action to move the focus to the specified field or control in the current record of the open form, form datasheet, table datasheet, or query datasheet. You can use this action when you want a particular field or control to have the focus. This field or control can then be used for comparisons or FindRecord actions. You can also use this action to navigate in a form according to certain conditions. For example, if the user enters No in a Married control on a health insurance form, the focus can automatically skip the Spouse Name control and move to the next control.

Setting

The GoToControl action has the following argument.

Action argument

Description

Control Name

The name of the field or control where you want the focus. Enter the field or control name in the Control Name box in the Action Arguments section of the Macro window. This is a required argument.

Note Enter only the name of the field or control in the Control Name argument, not the fully qualified identifier, such as Forms!Products![Product ID].


Remarks

You can't use the GoToControl action to move the focus to a control on a hidden form.

Tip You can use the GoToControl action to move to a subform, which is a type of control. You can then use the GoToRecord action to move to a particular record in the subform. You can also move to a control on a subform by using the GoToControl action to move first to the subform and then to the control on the subform.

To run the GoToControl action in Visual Basic, use the GoToControl method of the DoCmd object. You can also use the SetFocus method to move the focus to a control on a form or any of its subforms, or to a field in an open table, query, or form datasheet.

See Also

GoToControl method, GoToPage action, GoToRecord action, SelectObject action, SetFocus method.