combo box options code

N

newby

I have a COMBO box where there are different values/options to choose from
including "Others" and I only want the "other specify" textbox to be visible
if only they choose the option "Others". Could someone kindly help me write
the code?
 
D

Daryl S

Newby -

Here is the basic code. You will need to change the names of the text box
and the combobox to be your names. Also, I assume the "Others" is in the
first column of the combo box (Column(0)).

Me.txtOtherSpecify.visible = (Me.cboBox.Column(0) = "Others")

The right part of this statement that is between parentheses will evaluate
to True or False, and will thus set the .visible property of the text
accordingly.

Depending on the use of your form, you would want this code in the OnClick
event of the combo box, but you might also want it in the OnCurrent event of
the form, so it displays properly for any existing record.
 
N

newby

Hi Daryl -

For some reasons, the code is not working and I don't know what I am doing
wrong, it keeps highlighting the "column" part. The "Other, please specify"
is in column (4) as in I have 5 options that I typed in by myself (did not
use the wizard). Could you kindly tell me what I am doing wrong? This is my
code:
Me.IfNoTypCnst_plsSpfy.visible = (Me.IfNoTypCnst.Column(4) = “Other, please
specifyâ€)

Thanks.
 
D

Daryl S

Newby -

The 4th column in the combo box would be column(3), as the first column is
column(0).
 

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