Hiding Buttons

K

Ken

What would be the best way to hide a button during the codes execution.
ie I have a button that when pressed, performs some actions. Before exiting
from the buttons on_click procedure, I want the button to become invisible.
Most things I have tries so far give an error along the lines of..
cannot change X when [button] control has focus.

Thank you in advance
 
D

Dennis

The error message tells you what you need to do before you can hide the button.
Move the focus to the most relevant button or control on youir form before
hiding
the one you have just clicked.

SomeOtherButton.SetFocus
SomeControl.SetFocus
 
K

Ken

Obvious!.. its been a long day,
cheers

Dennis said:
The error message tells you what you need to do before you can hide the button.
Move the focus to the most relevant button or control on youir form before
hiding
the one you have just clicked.

SomeOtherButton.SetFocus
SomeControl.SetFocus

Ken said:
What would be the best way to hide a button during the codes execution.
ie I have a button that when pressed, performs some actions. Before exiting
from the buttons on_click procedure, I want the button to become invisible.
Most things I have tries so far give an error along the lines of..
cannot change X when [button] control has focus.

Thank you in advance
 
D

David C. Holley

Access doesn't like it when you try to hide a control that has the focus
(or I presume change the ENABLE property). The trick is to shift the
focus and then change the property. So try

Sub mySub()
Me.someOtherControl.SetFocus
Me.cmdButtonName.Enable = False



I recommend changing the enable property since visually it makes a bit
more sense.
 
Top