Set Focus within the subform?

  • Thread starter Thread starter MLD
  • Start date Start date
M

MLD

not sure if this should be going to the Forms group, but here goes.
I have a form/subform which when opened, needs to begin editing in the first
field of the subform dispalyed as a data table. What is the correct way to
SetFocus on this field? My tab order in the sub is correct, but I can't get
it to properly select on open.

Thanks,
-Monica
(e-mail address removed)
 
Try this in the On Open Event of the main form:

Private Sub Form_Open(Cancel As Integer)
Me.My_sub_frm.SetFocus
Me.My_sub_frm("MyControlName").SetFocus
End Sub
 
I might use the on current event for the form.

[Form_YourFormName]![YourFieldName].setfocus

Sometimes in code.

[Form_MainFormName]![Subform]![YourFiled].setfocus

me!subform!field.setfocus is almost equivalent
 
Monica

As Jl5000 and SacCourt have both intimated, this can be done with VBA
procedures. However, as this is a macros newsgroup, maybe you want to
do this with a macro. If so, you need to use two GoToControl actions.
The first one will move to the subform control, and the second one will
move to the required control within the subform. Something like this...
Action: GoToControl
Control Name: [Forms]![NameOfMainForm]![NameOfSubform]
Action: GoToControl
Control Name: [Forms]![NameOfMainForm]![NameOfSubform]![NameOfControl]
Assign this macro on the On Open event property of the main form.
 
Back
Top