Conditionally enable a command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I've tried to design a command button that would only be enabled if a
particular textbox is dirty. But it doesn't seem to work. Can someone please
correct me?

Private Sub Type_Dirty(Cancel As Integer)
' Enable cbEditExistingType only if Type textbox is dirty
cbEditExistingType.Enabled = True
End Sub
 
In addition to this, you also need to "disable" the textbox after your form
is saved. You can try the AfterUpdate event of the FORM:

Sub Form_AfterUpdate
cbEditExistingType.Enabled = False
End Sub

You can also disable this in the button's Click event:

Sub cbEditExistingType_Click()
'/move the focus off this button, since you can't disable a control that
has the focus
Me.SomeOtherControl.Setfocus
Me.cbEditExistingType.Enabled = False
End Sub
 
Back
Top