How do I set a visible property conditionally?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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..
 
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.
 
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
 
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.
 
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* ;)
 
I put in what you suggested, however it doesn't recognize after_change()
did you mean after_update?
Thanks
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
 
Hi I have a bunch of text boxes on my access report that I would like to appear visible or invisible based on another textbox(say txtbox A) having a value or being visible.

I tried to put a code into the visible property option of the selected group of txt boxes. but it didnt work out.

Any suggestion because I am new with Access
 
Back
Top