Microsoft KB Archive/95014
Article ID: 95014
Article Last Modified on 1/18/2007
- Microsoft Access 1.0 Standard Edition
- Microsoft Access 1.1 Standard Edition
- Microsoft Access 2.0 Standard Edition
- Microsoft Access 95 Standard Edition
- Microsoft Access 97 Standard Edition
This article was previously published under Q95014
Novice: Requires knowledge of the user interface on single-user computers.
To set the focus to a control on a subform, you can create a macro that uses the GoToControl action to first move to the subform (which is a type of a control), and then uses the GoToControl action again to move to a particular control on the subform.
NOTE: This article explains a technique demonstrated in the sample files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0) and FrmSmp97.exe (for Microsoft Access 97). For information about how to obtain these sample files, please see the following articles in the Microsoft Knowledge Base:
150895 ACC95: Microsoft Access Sample Forms Available in Download Center
175066 ACC97: Microsoft Access 97 Sample Forms Available in Download Center
The macro action GoToControl does not allow you to use the full syntax for the ControlName argument as:
Forms![orders]![orders subform]![ProductID] NOTE: In versions 1.x and 2.0, there is a space in Product ID field name.
If you use this syntax, you may receive the following error message:
To work around this behavior, you need to set up a macro that first sets the focus to the subform control, and then sets the focus to a specific control on the subform.
The following example uses the sample database Northwind.mdb (or NWIND.MDB in version 2.0 or earlier) to demonstrates this technique.
CAUTION: Following the steps in this example will modify the sample database Northwind.mdb (or NWIND.MDB in version 2.0 or earlier). You may want to back up the Northwind.mdb (or NWIND.MDB) file and perform these steps on a copy of the database.
- Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0 or earlier).
Create the following new macro called GoToSubform:
Macro Name Macro Actions ----------------------------- GoToSubform GoToControl GoToControl GoToSubform Actions ------------------------------- GoToControl Control Name: Orders Subform GoToControl Control Name: ProductID (or Product ID in version 1.x or 2.0)
- Open the Orders form in Design view.
Add a command button to the form and set the following properties:
Caption: Enter/Modify Orders OnClick (or OnPush in 1.x): GoToSubform
- Open the Orders form in Form view. Click the Enter/Modify Orders button and note that the insertion point moves to the Product field (or the Prod ID field in version 1.x or 2.0) on the Orders subform.
For more information about moving to a specific control, search for "GotoControl action" using the Microsoft Access 97 Help Index.
Additional query words: how to
Keywords: kbhowto kbusage KB95014