Link to home
Start Free TrialLog in
Avatar of thandel
thandel

asked on

How do get focus to a particular field

I have a form that contains a sub form which contains another subform.  I need to get focus to a particular field on the 2nd sub form.  The user could be any where in the main form, sub form or the sub-sub form.  

How can I code in a way to get to a text box in the sub-sub-form?  I know there is me and me.parent (??) but it isn't always working depending on where the user is when the present code is executed.

Thank you.
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Depends on where your coding takes place. Let's imagine it's the main form:

    Me.subControlName.SetFocus
    Me.subControlName.Form.subSubControlName.SetFocus
    Me.subControlName.Form.subSubControlName.Form.ControlName.SetFocus

(°v°)
Avatar of thandel
thandel

ASKER

I guess that is the issue.... I don't know where the user is when the macro is executed.
It isn't. The question is only from where the code will be run. If it's a macro, your safest bet is to fully specify everything. Replace Me. with the full reference Forms!frmYourMainForm. and you will be ok.

(°v°)
Avatar of thandel

ASKER

OK, but I"m not using VB but rahter the Macro gui... is your solution possible?
ASKER CERTIFIED SOLUTION
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial