PC Review


Reply
Thread Tools Rate Thread

Confused about setfocus

 
 
Mo
Guest
Posts: n/a
 
      12th Oct 2011
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.
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      12th Oct 2011
On Wed, 12 Oct 2011 14:28:56 +0100, Mo <(E-Mail Removed)> 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/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
Mo
Guest
Posts: n/a
 
      12th Oct 2011

> 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!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 AM.