How do I set a visible property conditionally?

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

Guest

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* ;)
 
G

Guest

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

Guest

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
 
Joined
Aug 2, 2011
Messages
1
Reaction score
0
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
 

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