If you disabled a command button in the validate event of a textbox and then try to click on that command button from the textbox, the command button's click event will not fire because the validate event fired first disabling the button. But if instead of clicking you use the command button's access key you'll notice that the button still becomes disabled but this time fires the click event.
Here is some code to demonstrate.
Option Explicit
Private Sub Form_Load()
Command1.Caption = "&Command1"
Text1.TabIndex = 0
End Sub
Private Sub Command1_Click()
MsgBox "Command1 Clicked"
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
'Bad data so disable command1
Command1.Enabled = False
MsgBox "Command1 is now disabled."
End Sub
Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
Here is some code to demonstrate.
Option Explicit
Private Sub Form_Load()
Command1.Caption = "&Command1"
Text1.TabIndex = 0
End Sub
Private Sub Command1_Click()
MsgBox "Command1 Clicked"
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
'Bad data so disable command1
Command1.Enabled = False
MsgBox "Command1 is now disabled."
End Sub
Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.