How do I set a visible property conditionally?

M

Maria

I am setting up a database in Access.
I have a drop down menu with "other" as a choice (For example: How would you
describe your race? Caucasian/Asian/African American/Other). I want to have a
text box appear when "other" is chosen, so that the person filling out the
form can type in a response. If "other" is not chosen from the drop down
menu, I'd like the textbox for "other" to hide, so there won't be any
mistakes in data entry.
I have already set up the combo box and then a text box next to it. I am
new to access, so if you respond please try to give explicit step by step
instructions. I have been trying to figure out the solution to this on my
own for a few weeks now. I really appreciate any help you lend..
 
F

fredg

I am setting up a database in Access.
I have a drop down menu with "other" as a choice (For example: How would you
describe your race? Caucasian/Asian/African American/Other). I want to have a
text box appear when "other" is chosen, so that the person filling out the
form can type in a response. If "other" is not chosen from the drop down
menu, I'd like the textbox for "other" to hide, so there won't be any
mistakes in data entry.
I have already set up the combo box and then a text box next to it. I am
new to access, so if you respond please try to give explicit step by step
instructions. I have been trying to figure out the solution to this on my
own for a few weeks now. I really appreciate any help you lend..

Code the Combo Box AfterUpdate event:
Me![ControlName].Visible = Me![ComboName] = "Other"

Place the same code in the Form's Current event.

Change ControlName to the actual name of the text control you wish to
hide/show.
Change ComboName to the name of the combo box.
 
V

Vsn

first in the properties of your textbox set value visible to FALSE

then some VBA code for the combobox after_change event

sub combobox after_change()
if combobox="other" then
textbox.visible = TRUE
else
textbox.visible = False
end if
end sub

was that what you where looking for?

Ludovic
 
V

Vsn

this is way smarter, as my suggestion. Thx, Ludovic.

fredg said:
I am setting up a database in Access.
I have a drop down menu with "other" as a choice (For example: How would
you
describe your race? Caucasian/Asian/African American/Other). I want to
have a
text box appear when "other" is chosen, so that the person filling out
the
form can type in a response. If "other" is not chosen from the drop down
menu, I'd like the textbox for "other" to hide, so there won't be any
mistakes in data entry.
I have already set up the combo box and then a text box next to it. I am
new to access, so if you respond please try to give explicit step by step
instructions. I have been trying to figure out the solution to this on
my
own for a few weeks now. I really appreciate any help you lend..

Code the Combo Box AfterUpdate event:
Me![ControlName].Visible = Me![ComboName] = "Other"

Place the same code in the Form's Current event.

Change ControlName to the actual name of the text control you wish to
hide/show.
Change ComboName to the name of the combo box.
 
V

Vantastic

Vsn said:
this is way smarter, as my suggestion. Thx, Ludovic.

Agreed. Sometimes I forget about 'reverse coding' stuff like this... :D

*Goes and re-writes an entire years worth of bad-coding* ;)
 
M

Maria

I put in what you suggested, however it doesn't recognize after_change()
did you mean after_update?
Thanks
Maria
 
M

Maria

I used after update and it worked! Thank you!!

Maria said:
I put in what you suggested, however it doesn't recognize after_change()
did you mean after_update?
Thanks
Maria
 
Top