incapacitate a button depending if has some written

F

Frank Dulk

as I do to enable or to incapacitate a button depending if has some written
thing or not in a text box

Example:

if I type some thing in the text box, it enables the button and if me
delete, incapacitates the button.
 
D

Douglas J. Steele

In the text box's AfterUpdate event, put code like:

Me.cmdMyButton.Enabled = Len(Me.txtMyTextbox & vbNullString) = 0

Replace cmdMyButton and txtMyTextbox with the names of your controls.
 
D

Douglas J. Steele

On second thought, you may want parentheses in there to make it more
readable.

Me.cmdMyButton.Enabled = (Len(Me.txtMyTextbox & vbNullString) = 0)

If the length of the text in the textbox is 0, (Len(Me.txtMyTextbox &
vbNullString) = 0) evaluates to True, so the button is enabled. If the
length of the text in greater than 0, it evaluates to False, so the button
is not enabled.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top