Buttons enabled/disabled

A

acores

Hello.
Is possible to enable/disable a button in a form, depending on the value of
a certain text field?
Thank you.
Acores
 
D

Douglas J. Steele

Sure. In the form's Current event, put code like:

Me.MyButton.Enabled = (Me.MyTextField = "ABC")

to only have the button enabled if the text field contains ABC.
 
A

acores

Hello, Douglas. Thank you for your quick answer.
However, I think the problem is a little more complicated than that... maybe
I simplified it too much...
The real situation is:
I have in a form three buttons: button_1, button_2 and button_3. What I want
is when a field have the text «Button1» for example, all the buttons are
disabled except button_1, if the field value is «Button2», all the buttons
are disabled but the button_2, and so on...
I already tried your solution in the form's Current event, but when I change
de field value, everything stays the same...

Me.Button_1.Enabled = (Me.Text.field = "Button1")
Me.Button_2.Enabled = (Me.Text.field = "Button2")
Me.Button_3.Enabled = (Me.Text.field = "Button3")

Thank you for your help.
Acores



"Douglas J. Steele" escreveu:
 
D

Douglas J. Steele

In my sample. I assumed that the text box was named MyTextField. You're
using Me.Text.field, which isn't valid (the .field part)
 
R

Ron2006

You ALSO have to execute the same conditional code in the Afterupdate
event of the text field.


Ron
 
Top