SetFocus Problem

S

Sharkbyte

I am experiencing an issue where I call a form, as a dialog. When the 2nd
form has completed its work, I call a function that may include setting a
number of buttons, on the first form, to Enabled = False.

When I do this I am continually stopped by one button, where I am told that
I cannot change its status, because it has Focus.

I have tried moving the focus earlier in the same code snippet. I have
tried moving the focus BEFORE calling the form. Nothing seems to work.

Any ideas?

TIA

Sharkbyte
 
M

Mark Andrews

You just need to move the focus to another control before you set enabled =
false on that control.
If you have any buttons that don't get enabled = false (that would be a good
choice)

Sounds like you had the right idea (look at the code more closely).

I do this all the time and run into this issue all the time,
Mark
 
S

Sharkbyte

Mark:

Thanks for your reply; however, I mentioned in my first email that I moved
focus before the line of code. (This would be the standard, first thing to
do...)

Here is a sample of the code. The ** line is where the problem occurs. The
## line is the line it stops at if I comment out the first problem...

[Forms]![frmcreateinvoice]![cmdChangePO].SetFocus
[Forms]![frmcreateinvoice]![cmdClose].SetFocus
[Forms]![frmcreateinvoice]![cmdChangePO].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddFee].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote1].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote2].Enabled = Fals
**[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdAddInvoicePart].Enabled = False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdDeletePart].Enabled =
False

##[Forms]![frmcreateinvoice]![subfrmCreateInvoice4]![cmdDeleteServiceFee].Enabled = False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdAddMisc].Enabled =
False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdDeleteMisc].Enabled =
False
 
M

Mark Andrews

As a guess you need to change the focus on the subform
[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]
so it's not on button
cmdAddInvoicePart

You are just changing focus on the main form.

If that doesn't work let me know I'll look deeper.

Mark



Sharkbyte said:
Mark:

Thanks for your reply; however, I mentioned in my first email that I moved
focus before the line of code. (This would be the standard, first thing
to
do...)

Here is a sample of the code. The ** line is where the problem occurs.
The
## line is the line it stops at if I comment out the first problem...

[Forms]![frmcreateinvoice]![cmdChangePO].SetFocus
[Forms]![frmcreateinvoice]![cmdClose].SetFocus
[Forms]![frmcreateinvoice]![cmdChangePO].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddFee].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote1].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote2].Enabled = False
**[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdAddInvoicePart].Enabled
= False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdDeletePart].Enabled
=
False

##[Forms]![frmcreateinvoice]![subfrmCreateInvoice4]![cmdDeleteServiceFee].Enabled
= False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdAddMisc].Enabled =
False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdDeleteMisc].Enabled
=
False


Mark Andrews said:
You just need to move the focus to another control before you set enabled
=
false on that control.
If you have any buttons that don't get enabled = false (that would be a
good
choice)

Sounds like you had the right idea (look at the code more closely).

I do this all the time and run into this issue all the time,
Mark




.
 
S

Sharkbyte

Mark:

I had thought of this, as well. No joy.

I did; however, find a workaround. I modified each button to check the same
value I was using to determine the Enabled flag. If the value is correct,
then I Exit Sub rather than processing the code.

The button remains Enabled...it just doesn't do anything.

Thanks for your ideas.


Mark Andrews said:
As a guess you need to change the focus on the subform
[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]
so it's not on button
cmdAddInvoicePart

You are just changing focus on the main form.

If that doesn't work let me know I'll look deeper.

Mark



Sharkbyte said:
Mark:

Thanks for your reply; however, I mentioned in my first email that I moved
focus before the line of code. (This would be the standard, first thing
to
do...)

Here is a sample of the code. The ** line is where the problem occurs.
The
## line is the line it stops at if I comment out the first problem...

[Forms]![frmcreateinvoice]![cmdChangePO].SetFocus
[Forms]![frmcreateinvoice]![cmdClose].SetFocus
[Forms]![frmcreateinvoice]![cmdChangePO].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddFee].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote1].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote2].Enabled = False
**[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdAddInvoicePart].Enabled
= False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdDeletePart].Enabled
=
False

##[Forms]![frmcreateinvoice]![subfrmCreateInvoice4]![cmdDeleteServiceFee].Enabled
= False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdAddMisc].Enabled =
False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdDeleteMisc].Enabled
=
False


Mark Andrews said:
You just need to move the focus to another control before you set enabled
=
false on that control.
If you have any buttons that don't get enabled = false (that would be a
good
choice)

Sounds like you had the right idea (look at the code more closely).

I do this all the time and run into this issue all the time,
Mark

I am experiencing an issue where I call a form, as a dialog. When the
2nd
form has completed its work, I call a function that may include setting
a
number of buttons, on the first form, to Enabled = False.

When I do this I am continually stopped by one button, where I am told
that
I cannot change its status, because it has Focus.

I have tried moving the focus earlier in the same code snippet. I have
tried moving the focus BEFORE calling the form. Nothing seems to work.

Any ideas?

TIA

Sharkbyte


.


.
 
M

Mark Andrews

If you want to shoot me a sample db with the original problem, I'll take a
look.
I don't think your workaround is needed (although it works and not too bad).

See contact info (email) on my site
Mark
RPT Software
http://www.rptsoftware.com




Sharkbyte said:
Mark:

I had thought of this, as well. No joy.

I did; however, find a workaround. I modified each button to check the
same
value I was using to determine the Enabled flag. If the value is correct,
then I Exit Sub rather than processing the code.

The button remains Enabled...it just doesn't do anything.

Thanks for your ideas.


Mark Andrews said:
As a guess you need to change the focus on the subform
[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]
so it's not on button
cmdAddInvoicePart

You are just changing focus on the main form.

If that doesn't work let me know I'll look deeper.

Mark



Sharkbyte said:
Mark:

Thanks for your reply; however, I mentioned in my first email that I
moved
focus before the line of code. (This would be the standard, first
thing
to
do...)

Here is a sample of the code. The ** line is where the problem occurs.
The
## line is the line it stops at if I comment out the first problem...

[Forms]![frmcreateinvoice]![cmdChangePO].SetFocus
[Forms]![frmcreateinvoice]![cmdClose].SetFocus
[Forms]![frmcreateinvoice]![cmdChangePO].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddFee].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote1].Enabled = False
[Forms]![frmcreateinvoice]![cmdAddNote2].Enabled = False
**[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdAddInvoicePart].Enabled
= False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice9]![cmdDeletePart].Enabled
=
False

##[Forms]![frmcreateinvoice]![subfrmCreateInvoice4]![cmdDeleteServiceFee].Enabled
= False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdAddMisc].Enabled
=
False

[Forms]![frmcreateinvoice]![subfrmCreateInvoice11]![cmdDeleteMisc].Enabled
=
False


:

You just need to move the focus to another control before you set
enabled
=
false on that control.
If you have any buttons that don't get enabled = false (that would be
a
good
choice)

Sounds like you had the right idea (look at the code more closely).

I do this all the time and run into this issue all the time,
Mark

I am experiencing an issue where I call a form, as a dialog. When
the
2nd
form has completed its work, I call a function that may include
setting
a
number of buttons, on the first form, to Enabled = False.

When I do this I am continually stopped by one button, where I am
told
that
I cannot change its status, because it has Focus.

I have tried moving the focus earlier in the same code snippet. I
have
tried moving the focus BEFORE calling the form. Nothing seems to
work.

Any ideas?

TIA

Sharkbyte


.


.
 

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