Re: Command Button Enabled/Disabled Based on Text in Text Box

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



A couple of comments about your code ---
1. Class1 is the name of a control on your form and should be enclosed in
square brackets not parantheses.
2. When referencing a control on a form, the control's name should be
proceeded by Me!
Me!Class1
Me!Class1LvlAdd
Me!Class1LvlRemove

(Buttons are controls!)

3. Indent your code lines between If and Else and Else and End If for
easier reading. Do the same for loops.

PS Apparently you caught my typo in Me1Class1LvlAdd.Enabled = True. The 1
after Me should be !.

PC Data***
Providing Customers A Resource For Help With Access, Excel And Word
Applications
resource@xxxxxxxxxxxxxxx



"DoveArrow" <DoveArrow@xxxxxxxxx> wrote in message
news:1185742053.023470.278640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 29, 1:38 pm, "Steve" <So...@xxxxxxxxxxxxxxxxxxxx> wrote:
Put the following code in the Current event of the form:

If Is Not Null [Class1] Then
Me1Class1LvlAdd.Enabled = True
Me!Class1LvlRemove.Enabled = True
End If

PC Data***
Providing Customers A Resource For Help With Access, Excel And Word
Applications
resou...@xxxxxxxxxxxxxxx

"DoveArrow" <DoveAr...@xxxxxxxxx> wrote in message

news:1185739757.265519.115270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



I'm trying to create a form where, if there is text in a text box, a
pair of command buttons will be enabled. I have figured out how to
make this work if the text box has been updated, but I can't figure
out how to make it work if there's already text in the box when the
form opens. If it helps, here's the code I've written to make the
buttons enable after text has been entered into the text box.

Private Sub Class1_Change()
If IsNull(Class1) Then
Class1LvlAdd.Enabled = False
Class1LvlRemove.Enabled = False
Else
Class1LvlAdd.Enabled = True
Class1LvlRemove.Enabled = True
End If
End Sub

Note: Right now, I'm taking my first baby steps into using Visual
Basic, so if the above looks laughably amateur, please be gentle.- Hide
quoted text -

- Show quoted text -

Fantastic! That works great! Thank you!



.


Quantcast