I actually had tried that already and it did not work. I found in the
archives a reference to this problem. The solution that was suggested was
the one I used - a dummy control is put on the form (in my case, a
transparent button hidded behind an existing button) and that gets the focus
so that the code does not blow up. Frankly, such a workaround seems stupid
to me. If, indeed, this is the only way to get the job done, then Microsoft
has committed a major screwup in my mind. While it may be that a control
that has focus cannot be disabled, it should be able to pass the focus
elsewhere and *not* to a dummy control hidden on a form!
Anyhow, this was the solution:
btnDummy.SetFocus
btn1.Enabled = False
btn2.Enabled = True
"Stewart Allen" <sa****@NOT.wave.THIS.co.nz> wrote in message
news:ca**********@news.wave.co.nz...
Try:
btn2.SetFocus
btn1.Enabled = False
btn2.Enabled = True
Stewart
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:K%Nxc.1919$eu.1185@attbi_s02...
I have 2 command buttons on a form. I want the first one to be enabled
and the second one to be disabled when the form is opened. That works fine.
Then, after the user has pressed the first button, I want them
reversed - button #2 is enabled and #1 is disabled.
But I keep getting this error message: "You can't disable a control
while it has the focus".
The code is basically this:
Upon open
btn1.Enabled = True
btn2.Enabled = False
After btn1 is pressed, do some stuff and then:
btn1.Enabled = False
btn2.Enabled = True
Do I need to move the last bit of code out of that sub or is there
something else that I need to do?