PC Review


Reply
Thread Tools Rate Thread

combo box options code

 
 
newby
Guest
Posts: n/a
 
      24th Mar 2010
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?

 
Reply With Quote
 
 
 
 
Daryl S
Guest
Posts: n/a
 
      24th Mar 2010
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.

--
Daryl S


"newby" wrote:

> 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?
>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      24th Mar 2010
Probably the After Update event of the combobox is the main event to use.

--
Steve Schapel, Microsoft Access MVP


"Daryl S" <(E-Mail Removed)> wrote in message
news:824C6B48-294A-436A-98F7-(E-Mail Removed)...
> 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.
>
> --
> Daryl S
>
>
> "newby" wrote:
>
>> 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?
>>

 
Reply With Quote
 
newby
Guest
Posts: n/a
 
      25th Mar 2010
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.

"Daryl S" wrote:

> 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.
>
> --
> Daryl S
>
>
> "newby" wrote:
>
> > 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?
> >

 
Reply With Quote
 
Daryl S
Guest
Posts: n/a
 
      25th Mar 2010
Newby -

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

--
Daryl S


"newby" wrote:

> 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.
>
> "Daryl S" wrote:
>
> > 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.
> >
> > --
> > Daryl S
> >
> >
> > "newby" wrote:
> >
> > > 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?
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter Combo Box Options based on other Combo Box Selection PVANS Microsoft Access Form Coding 1 11th Jan 2010 02:06 PM
Re: Options in combo based on previous combo Arvin Meyer [MVP] Microsoft Access Forms 0 22nd Jul 2009 04:42 AM
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf Microsoft Excel New Users 1 27th Mar 2009 06:29 PM
Combo Box Options =?Utf-8?B?V01vcnNiZXJnZXI=?= Microsoft Access 2 7th Aug 2006 08:45 PM
Using Yes/No as combo box options Allie Microsoft Access Forms 2 20th Jul 2004 06:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 PM.