What event to change a controls visible property

B

BT

Hello

I am trying to set a controls visible property depending on the contents of
a text box.

I have the following simple If/Else statement:

If Me.txtAnswer = "multiple" Then
Me.txtAddAnswer.Visible = yes
Else
Me.txtAddAnswer.Visible = no
End If

Will this code work ? What Event would this go in. Itried several an can not
get it to work proberly.

Thanks for your help
Brian
 
G

Gerald Stanley

The code should go into the AfterUpdate eventhandler of
txtAnswer.
The Visible property should be set to True or False not Yes
or No.

Hope This Helps
Gerald Stanley MCSD
 
F

fredg

Hello

I am trying to set a controls visible property depending on the contents of
a text box.

I have the following simple If/Else statement:

If Me.txtAnswer = "multiple" Then
Me.txtAddAnswer.Visible = yes
Else
Me.txtAddAnswer.Visible = no
End If

Will this code work ? What Event would this go in. Itried several an can not
get it to work proberly.

Thanks for your help
Brian

1) You can shorten your code to one line:

Me!txtAddAnswer.Visible = Me!txtAnswer = "multiple"

2) Where you place the line depends upon what you are doing.

If txtAnswer cannot be changed by the user, place the code in the
form's Current event only.

If txtAnswer can be changed by the user, place the code in the
txtAnswer AfterUpdate event AND in the Form's Current event.
 

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