subforms & focus

J

JP

Help!!!!

I have a form with a combo box and a subform.
The subform has a subform of its own as well.

The combo box on the main drives both subforms.

I want to disable both subforms while the combo box is
being used. So for the "gotFocus" event of the combo box
I have the following code:

subform1!subform2.Enabled = False
subform1.Enabled = False

This works if a control on subform1 previously had the
focus.

But if a control on subform2 previously had the focus, I
get an error message as soon as I click on the combo box.

The error message is:
Run-time error '2164':
You can't disable a control while it has the focus.

When I click 'Debug' it highlights
subform1!subform2.Enabled = False
in the combo box GotFocus event.

This is why I am confused.
Since I am in the combo box GotFocus event that means the
combo box has the focus. Therefore, I should be able to
disable the subforms.

Any ideas? Anyone? Anyone?
 
S

Sandra Daigle

Hi JP,

Try this, on the first subform create a textbox, name it txtDecoy (or
whatever you want). Make it .001 x .001, which makes it invisible yet still
able to receive the focus. Then change your GotFocus event to resemble the
following:

Me.frmOrders.Form.txtdecoy.SetFocus
Me.frmOrders.Enabled = False
Me.frmOrders.Form.sfrmOrderDetails.Enabled = False
 
J

JP

Sandra,

Thanks. That works.

But why does it work that way?
Do you have to back out one subform at a time?

Maybe I don't quite understand what "focus" means.
Doesn't the combo box have the focus as soon as you click
on it?

Thanks.

JP

-----Original Message-----
Hi JP,

Try this, on the first subform create a textbox, name it txtDecoy (or
whatever you want). Make it .001 x .001, which makes it invisible yet still
able to receive the focus. Then change your GotFocus event to resemble the
following:

Me.frmOrders.Form.txtdecoy.SetFocus
Me.frmOrders.Enabled = False
Me.frmOrders.Form.sfrmOrderDetails.Enabled = False


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Help!!!!

I have a form with a combo box and a subform.
The subform has a subform of its own as well.

The combo box on the main drives both subforms.

I want to disable both subforms while the combo box is
being used. So for the "gotFocus" event of the combo box
I have the following code:

subform1!subform2.Enabled = False
subform1.Enabled = False

This works if a control on subform1 previously had the
focus.

But if a control on subform2 previously had the focus, I
get an error message as soon as I click on the combo box.

The error message is:
Run-time error '2164':
You can't disable a control while it has the focus.

When I click 'Debug' it highlights
subform1!subform2.Enabled = False
in the combo box GotFocus event.

This is why I am confused.
Since I am in the combo box GotFocus event that means the
combo box has the focus. Therefore, I should be able to
disable the subforms.

Any ideas? Anyone? Anyone?

.
 

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