Kill Focus on Subform

  • Follow


Hi,

I have a main form with a bunch of subforms, let's call them A through G.

Each subform has its own group of subforms, let's call them 1-4.

So I have tons of subforms, like A1, B4, D3, etc.

I have some code that cycles through all the  lowest level subforms (like 
A3), and makes some visible and others invisible. I always hit an error that 
"You can't hide a control that has the focus."

I have desperately tried to set the focus elsewhere so I won't get the error 
but it doesn't work. If I try to set the focus to a different subform I get 
the error of "Microsoft Access can't move the focus to control Child47." 
(Child47 is the name of the subform.)

I'm losing my mind. Any ideas?

Thanks!!

John Schping
0
Reply Utf 3/17/2010 4:55:01 PM

On Wed, 17 Mar 2010 09:55:01 -0700, jschping
<jschping@discussions.microsoft.com> wrote:

Why not keep focus on the main form?
Assuming your code runs in the main form:
Me.SetFocus
Me.myAlwaysVisibleControl.SetFocus
'show and hide your subsubforms here.

-Tom.
Microsoft Access MVP



>Hi,
>
>I have a main form with a bunch of subforms, let's call them A through G.
>
>Each subform has its own group of subforms, let's call them 1-4.
>
>So I have tons of subforms, like A1, B4, D3, etc.
>
>I have some code that cycles through all the  lowest level subforms (like 
>A3), and makes some visible and others invisible. I always hit an error that 
>"You can't hide a control that has the focus."
>
>I have desperately tried to set the focus elsewhere so I won't get the error 
>but it doesn't work. If I try to set the focus to a different subform I get 
>the error of "Microsoft Access can't move the focus to control Child47." 
>(Child47 is the name of the subform.)
>
>I'm losing my mind. Any ideas?
>
>Thanks!!
>
>John Schping
0
Reply Tom 3/17/2010 9:54:14 PM


What would be the trigger that makes the subform or control not visbile? You 
might expect that it isn't possible to set a control (or object) to invisble 
when in fact it has the focus. So describe the functionality what you are 
trying to achive as follows:

when this happens the following should be inactive or set to invisble, also 
describe where the focus is at that point. That might give us some more info.
-- 
Maurice Ausum


"jschping" wrote:

> Hi,
> 
> I have a main form with a bunch of subforms, let's call them A through G.
> 
> Each subform has its own group of subforms, let's call them 1-4.
> 
> So I have tons of subforms, like A1, B4, D3, etc.
> 
> I have some code that cycles through all the  lowest level subforms (like 
> A3), and makes some visible and others invisible. I always hit an error that 
> "You can't hide a control that has the focus."
> 
> I have desperately tried to set the focus elsewhere so I won't get the error 
> but it doesn't work. If I try to set the focus to a different subform I get 
> the error of "Microsoft Access can't move the focus to control Child47." 
> (Child47 is the name of the subform.)
> 
> I'm losing my mind. Any ideas?
> 
> Thanks!!
> 
> John Schping
0
Reply Utf 3/17/2010 10:04:01 PM

2 Replies
217 Views

(page loaded in 0.074 seconds)


Reply: