Confused about setfocus

October 12th, 2011 - 09:28 am ET by Mo | Report spam
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.
email Follow the discussionReplies 2 repliesReplies Make a reply

Similar topics

Replies

#1 John W. Vinson
October 12th, 2011 - 11:30 am ET | Report spam
On Wed, 12 Oct 2011 14:28:56 +0100, Mo wrote:

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/Fo...accessdev/
http://social.answers.microsoft.com...US/addbuz/
and see also http://www.utteraccess.com
Replies Reply to this message
#2 Mo
October 12th, 2011 - 11:48 am ET | Report spam
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!
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search