DoCmd.GoToControl method (Access)
The GoToControl method performs the GoToControl action in Visual Basic.
expression A variable that represents a DoCmd object.
|ControlName||Required||Variant||A string expression that is the name of a control on the active form or datasheet.|
You can use the GoToControl method 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 method 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 method 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/partner Name control and move to the next control.
You cannot use the GoToControl method to move the focus to a control on a hidden form.
Use only the name of the control for the ControlName argument, not the full syntax.
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. This is the preferred method for moving the focus in Visual Basic, especially to controls on subforms and nested subforms, because you can use the full syntax to specify the control that you want to move to.
You can use the GoToControl method to move to a subform, which is a type of control. You can then use the GoToControl method to move to a particular record in the subform. You can also move to a control on a subform by using the GoToControl method to move first to the subform and then to the control on the subform.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.