If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Enabling a field based on a combo box
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! |
#2
|
|||
|
|||
Enabling a field based on a combo box
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. -- hth Al Camp Candia Computer Consulting - Candia NH http://home.comcast.net/~cccsolutions "AccessNovice" wrote in message ... 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! |
#3
|
|||
|
|||
Enabling a field based on a combo box
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! "Al Camp" wrote: 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. -- hth Al Camp Candia Computer Consulting - Candia NH http://home.comcast.net/~cccsolutions "AccessNovice" wrote in message ... 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! |
#4
|
|||
|
|||
Enabling a field based on a combo box
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? "AccessNovice" wrote: 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! |
#5
|
|||
|
|||
Enabling a field based on a combo box
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... -- hth Al Camp Candia Computer Consulting - Candia NH http://home.comcast.net/~cccsolutions "AccessNovice" wrote in message ... 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! "Al Camp" wrote: 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. -- hth Al Camp Candia Computer Consulting - Candia NH http://home.comcast.net/~cccsolutions "AccessNovice" wrote in message ... 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! |
#6
|
|||
|
|||
Enabling a field based on a combo box
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. -- hth Al Camp Candia Computer Consulting - Candia NH http://home.comcast.net/~cccsolutions "AccessNovice" wrote in message ... 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? "AccessNovice" wrote: 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! |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do I establish a Many-to-Many Relationship | jmcarroll7 | Setting Up & Running Reports | 13 | February 24th, 2006 09:06 PM |
Memo Field | Sam | General Discussion | 12 | November 10th, 2005 09:16 PM |
Multiple Options Group | Patty Stoddard | Using Forms | 19 | August 4th, 2005 02:30 PM |
Office 2003 installation problem, log file attached.... | Ryan | Setup, Installing & Configuration | 0 | January 20th, 2005 06:57 PM |
Combo field based on a combo field | Kyle B. | New Users | 3 | June 4th, 2004 02:14 AM |