Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Enabling a field based on a combo box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AccessNovice - 09 Mar 2006 07:02 GMT
I have created a combo box with 5 drop down choices.  I want a date to be
enabled if the user chooses 3 out of the five choices, otherwise i want the
date field to be disabled.  I know how to do this for a yes/no combo box, but
not if there is more than one choice. Any advice would be greatly appreciated!
Al Camp - 09 Mar 2006 13:34 GMT
  I'm going to assume that your using a Value List for your combo...

  1. You could just set up a CaseSelect that would evaluate the combo
selection, and enable or disable accordingly.  Check out Help on how to set
up a CaseSelect... it's pretty straight forward, and eassier to set up for a
newbie than a "nested" IIF statement.

  2. The next solution would be to make the combo two columns.  The first
column would be the value you want to select, the second would be a Yes or
No accordingly.  Your value list would look like this...
       Value1, Yes ; Value2, Yes ; Value3, No    ... etc

  On the AfterUpdate event of your combo...
       IF cboYourComboName.Column(1) = "Yes" Then
           Then YourDateField.Enabled = True
       Else
           YourMyDateField.Enabled = False
       End if

   **Use this same code behind the OnCurrent event of the form itself, so
that the enabling/disabling is always in synch with the combo selection.
----------------------------------------------------------------------
  3. Since a change in the number of combo options might change in the
future, the best method is to store the Yes/No value with the combo values
in a seperate table, and use that little 2 column table as the RowSource for
your combo... rather than a ValueList.
Ex.
Value     HasDate
ABC      Yes
CDE      Yes
FGH       No   etc... etc...
That way, if a sixth or seventh item is ever added, you just add that choice
to the table, with an approprite Yes or No, and nothing in your forms or
reports coding has to be re-edited to "evaluate" if that entry requires a
Date or not.
Signature

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

>I have created a combo box with 5 drop down choices.  I want a date to be
> enabled if the user chooses 3 out of the five choices, otherwise i want
[quoted text clipped - 3 lines]
> not if there is more than one choice. Any advice would be greatly
> appreciated!
AccessNovice - 09 Mar 2006 15:35 GMT
hi, thanks for the advice! i tried choice #2 - creating a combo box with two
columns, one with the value and the second with Yes or No.  However, for some
reason this isn't working. I tried

cboCurrent_status_of_dog.Column(1) = "Yes" then
Date_of_death.Enabled = True
Else
Date_of_death.Enabled = False
End if

And i used the same code behind the Oncurrent event of the form itself.
For some reason the code doesn't like the "cbo" part.....and then i tried
Me.Current_status_of_dog, and that didn't produce an error, but it didn't
work either.

What is cbo and am I doing this right?

Thanks so much for your help, I greatly appreciate it!

>    I'm going to assume that your using a Value List for your combo...
>
[quoted text clipped - 38 lines]
> > not if there is more than one choice. Any advice would be greatly
> > appreciated!
Al Camp - 09 Mar 2006 16:40 GMT
Did you set the NOOfColumns property to 2, and set the ColumnWidth to
something like 1" ; .5", and the ListWidth to 1.5", and set the BoundColumn
to 1?
Can you see the two columns when you drop down the combo?

Have you used EventProcedures before?  Sounds like your code is not entered
properly.  Just to review...
1. Go to the AfterUpdate event of your combo, and place you cursor in the
text box associated with that event.
2. Using the little down arrow on the right, select Event Procedure
3. Click the button with 3 dots ( ... ) to the right.
4. Your EventProcedure code behind the combo AfterUpdate event should look
like this...
   Private Sub cboCurrent_status_of_dog_AfterUpdate()
       If cboCurrent_status_of_dog.Column(1) = "Yes" Then
           Date_of_death.Enabled = True
       Else
           Date_of_death.Enabled = False
       End if
    End sub
5. Repeat this process with the AfterUpdate event of Form OnCurrent...
Signature

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

> hi, thanks for the advice! i tried choice #2 - creating a combo box with
> two
[quoted text clipped - 69 lines]
>> > not if there is more than one choice. Any advice would be greatly
>> > appreciated!
AccessNovice - 09 Mar 2006 15:37 GMT
I actually just got it to work using Me.current_status_of_dog instead of the
cbo prefix. thanks so much for the help!

ps - what does cbo mean?

> I have created a combo box with 5 drop down choices.  I want a date to be
> enabled if the user chooses 3 out of the five choices, otherwise i want the
> date field to be disabled.  I know how to do this for a yes/no combo box, but
> not if there is more than one choice. Any advice would be greatly appreciated!
Al Camp - 09 Mar 2006 16:46 GMT
  I missed this post before I re-replied... so disregard my post.  Sounds
like your OK now.  Good deal!
  "cbo" is a naming convention in Access that identifies that control as a
combobox.  lstMyList would indicate a ListBox.. etc..
  It is not critical to use naming conventions... whatever you name the
control... that's what you need to refer to in your code

  If you named your combo Current_Status_Of_Dog, then you need to use that
name.
Signature

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

>I actually just got it to work using Me.current_status_of_dog instead of
>the
[quoted text clipped - 9 lines]
>> not if there is more than one choice. Any advice would be greatly
>> appreciated!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.