DoCmd GotoControl in Microsoft Access

 

Docmd GotoControl Access Example

The DoCmd GoToControl method moves the cursor (sets focus to) a field or control on a form in VBA.The control name is the only option available for the Goto Control statement:

Access Docmd GotoControl Method Example

ControlName: The name of a field or a control where you desire the focus to go. The control name can be a string expression, ie., “OK_Button”, as in the visual basic example above, or it can be a variable which contains the name of a control on the form – note: no spaces are allowed in the name. Consider using the Setfocus command in place of the DoCmd.GotoControl command because the set focus command has increased functionality.

Note that you may employ the GoTo Control method to move to a subform, which is a type of control. You can then use the GoToRecord method to move to a specific 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 secondly to a control within subform.

More GotoControl Examples:

NotInList Event with Goto Control

FindFirst Recordset with Goto Control Visual Basic