Confused about setfocus

M

Mo

Hello,

I'm trying to set the focus to a control on a subform from another
subform and I'm using the following:

Private Sub cmbMParentSiblings_Exit(Cancel As Integer)

Forms!frmperson!frmFatherSub.Form!cmbFather.SetFocus

End Sub

It doesn't work. There's no error message, but the focus just cycles
back through the controls on the first subform.

What am I doing wrong?

TIA for any help.
 
J

John W. Vinson

Hello,

I'm trying to set the focus to a control on a subform from another
subform and I'm using the following:

Private Sub cmbMParentSiblings_Exit(Cancel As Integer)

Forms!frmperson!frmFatherSub.Form!cmbFather.SetFocus

End Sub

It doesn't work. There's no error message, but the focus just cycles
back through the controls on the first subform.

What am I doing wrong?

TIA for any help.

Oddly, you need TWO Setfocus steps in sequence: first setting focus to the
Subform itself, then to the control on that subform. Try

Forms!frmperson!frmFatherSub.SetFocus
Forms!frmperson!frmFatherSub.Form!cmbFather.SetFocus

Alternatively, you can use the Parent! shortcut rather than the full parent
form reference:

Parent!frmFatherSub.SetFocus
etc.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
M

Mo

Oddly, you need TWO Setfocus steps in sequence: first setting focus to the
Subform itself, then to the control on that subform. Try

Forms!frmperson!frmFatherSub.SetFocus
Forms!frmperson!frmFatherSub.Form!cmbFather.SetFocus

Alternatively, you can use the Parent! shortcut rather than the full parent
form reference:

Parent!frmFatherSub.SetFocus
etc.

Thanks John. That worked perfectly!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top