Set Focus within the subform?

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
[email protected]
 
J

jl5000

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
 
S

SacCourt

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
 
Top