SetFocus Problem

S

Sharkbyte

When I run a series of code, running several Enabled = False commands, I keep
getting stopped with an error stating I can't disable a control w/ focus.
However, I have moved focus prior to this code executing.

I have included the code below. I have also tried other iterations, of this
code. I have moved focus earlier in the code, as well as moving focus to a
second control, first.

Any ideas why the focus continues to return to the control causing the error?

TIA --- Sharkbyte

Me.cmdChangePO.Enabled = False
Me.cmdAddFee.Enabled = False
Me.cmdAddNote1.Enabled = False
Me.cmdAddNote2.Enabled = False
Me.subfrmCreateInvoice11!cmdAddMisc.Enabled = False
Me.subfrmCreateInvoice11!cmdDeleteMisc.Enabled = False
Me.cmdClose.SetFocus
(Problem line) Me.subfrmCreateInvoice4!cmdDeleteServiceFee.Enabled = False
Me.subfrmCreateInvoice9!cmdAddInvoicePart.Enabled = False
Me.subfrmCreateInvoice9!cmdDeletePart.Enabled = False
 
M

Marshall Barton

Sharkbyte said:
When I run a series of code, running several Enabled = False commands, I keep
getting stopped with an error stating I can't disable a control w/ focus.
However, I have moved focus prior to this code executing.

I have included the code below. I have also tried other iterations, of this
code. I have moved focus earlier in the code, as well as moving focus to a
second control, first.

Any ideas why the focus continues to return to the control causing the error?

Me.cmdChangePO.Enabled = False
Me.cmdAddFee.Enabled = False
Me.cmdAddNote1.Enabled = False
Me.cmdAddNote2.Enabled = False
Me.subfrmCreateInvoice11!cmdAddMisc.Enabled = False
Me.subfrmCreateInvoice11!cmdDeleteMisc.Enabled = False
Me.cmdClose.SetFocus
(Problem line) Me.subfrmCreateInvoice4!cmdDeleteServiceFee.Enabled = False
Me.subfrmCreateInvoice9!cmdAddInvoicePart.Enabled = False
Me.subfrmCreateInvoice9!cmdDeletePart.Enabled = False


It's the Me.subfrmCreateInvoice4!cmdDeleteServiceFee control
that it's complaining about. It's not really the focus
that's causing the problem, it's the subform's active
control that you are running into. I suggest that you try
moving the subform's focus to a different control in the
subform control's Exit event.
 

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