MS Access 2003: Set the focus on second field in a subform whenever a record is viewed
This MSAccess tutorial explains how to set the focus on the second field in a subform whenever a record is viewed in Access 2003 (with step-by-step instructions).
Question: In Microsoft Access 2003/XP/2000/97, I have a form and a subform (master/detail relationship). The main form is in the Form Header section while the subform is in the Detail section. The problem is every time I add a new record, the cursor won't go to the second field in the subform.
For example, the subform contains the following fields:
- LINE_NUM
- LOAD_DATE
- LOAD_BY
I want the subform to move the cursor to the second field LOAD_DATE whenever adding a new record.
I used the DoCmd.GoToControl Me.LOAD_DATE on the subform's "On Current" event property but I'm getting an error. Please help.
Answer: To make sure that the focus is on the second field (ie: LOAD_DATE field) whenever a new record is added...or for that matter, whenever you view a record in the subform, try the following VBA code on the subform's "On Current" event:
LOAD_DATE.SetFocus
For example:
Private Sub Form_Current() LOAD_DATE.SetFocus End Sub
Advertisements