PDA

View Full Version : disalbe commandbutton



Augest
10-16-2008, 04:52 PM
How do I disable a commandbutton after the click event then enable when its not on focus?

fumei
10-20-2008, 01:01 PM
Huh? Want to try asking that again?

You want to be able to click it (so it IS enabled), and then after the click event, disable it? Then...ummmm, enable it again when it does not have focus?

That does not really make sense, although maybe it does...I am not sure. When a Click event terminates, the control no longer has focus. Something else does, unless of course you are unloading the userform. I am assuming this is a userform. If it is NOT a userform (say a ActiveX commandbutton in the document), then perhaps you had better state that.

So, you could disable the commandbutton when whatever is the next control does get focus.

Perhaps if you clearly and precisely tell us what you are trying to do?

Sub CommandButton1_Click()
CommandButton1.Enabled = False
End Sub

will disable CommandButton1. After the Click event terminates, the control is disabled, although technically speaking, the control is disabled BEFORE the Click event terminates.

Now you could use the Exit event, which fires AFTER the Click event. But I really do not know what you are trying to do.