Buttons enabled/disabled

G

Guest

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.
 
G

Guest

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
 

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

Similar Threads

Toolbar disabled 4
Button images 2
Macros with code 3
Shortcut menu 1
Actual date 1
Set a variable 3
Toolbar comand 3
% format 1

Top