Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on option group

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
option group can enable to choose one of the choice, right, if i choose one of them in option group, the combo box will enable and let the user to choose (the combo box will disable if the user doesn't choose that option), how can i do that? thanks

Option Group
0 Date1
0 Date2
0 Date3
|--------|
|______|_| <combo box>
 
Sorry, but could your rephrase your question?

It sounds like you have two different controls on your form, and Option Group with some dates, and a combo box with data.

Do you want the combobox to be enabled if ANY choice is made in the option group, or only if a certain choice is made?

Kathryn


 
actually, that's a sample i saw . . .
i checked it, but can't figure it out how it done . . .

it's a option group, if say that Option Group have 2 options: &quot;option 1&quot; &amp; &quot;option 2&quot;. But when i click the &quot;option 2&quot;, the Combo Box will enable and let me choose the value it set....

by the way, the Combo Box is &quot;Enable=No&quot; until i click the &quot;option 2&quot; , if i click the &quot;option 1&quot; that Combo Box will remain &quot;Enable=No&quot;. clear? or? thanks for your interest

i think you have guessed what i meant . . .
 
In the AfterUpdate event procedure for the option group you would use code to enable or disable other controls(you can even use it to set the rowsource SQL for the same combobox control, thereby having a single combobox that will use different recordsets as it's rowsource based on the option group choice). A good tool is to use Select Case.


...
Select Case Me.OptionGroupName

Case 1
Me.ComboboxName.Enable = False
Case 2
Me.ComboboxName.Enable = True
...
 
please see if anything goes wrong:

i tried to put it in &quot;On Current&quot;, &quot;After Update&quot; in the main form; and even put it in &quot;After Update&quot; ,&quot;On Enter&quot; of the combo box. i tried one by one.

Select Case Me.SortBy

Case 1
Me.Months.Enabled = False
Case 2
Me.Months.Enabled = True

End Select
 
It should be in the AfterUpdate event procedure for the combobox. Make sure that the value returned by Me.SortBy is in fact a 1 or 2. You can do this by putting this before the select case statement:

Debug.Print Me.SortBy

Open or view the immediate window and see what value is displayed after one is selected in the combobox.
 
when i put these code in After Update of the combox Box. nothing happens when i tick the option 1 as well as option 2.
when i put these code in Before Update, and any other Event column, and will display the error &quot;Object doesn't support this method&quot;. select Case Me.SortBy will be lightlight if i debug.

Select Case Me.SortBy

Case 1
Me.Months.Enabled = False
Case 2
Me.Months.Enabled = True

End Select

Debug.Print Me.SortBy
 
What part of &quot;putting the debug.print statement BEFORE the select case statement&quot; did you not understand? ;-)

The reason you're getting an error in the BeforeUpdate event of the optiongroup control is because it is null. You can't use null to test for Select Case. Move it to AfterUpdate.
 
hehe, sorry, too rush . . .
Sorry, i tried to put before &quot;Select Case&quot; statement and even put before End Select, it won't work.... why ????? there's no bug, but nothing happends too ....... i'm using Access 2000, anything goes wrong????
 
I believe the code needs to go in the After Update event of the option group, rather than the combobox, so that when an option is selected the case statement is read and the combobox is enabled or disabled as needed. Michelle Fulton

 
in the option group, cannot add any code inside ....... that's mean, there's no &quot;Event&quot; to chooce .......
 
Yes, there are events for the group but you have to select the group and not just one option. If you created the options as a group, there should be a frame around them and you need to click on the frame to go to the properties for the whole group. If you just put a couple of options out there without grouping them, you can put the code behind one option button and then copy it to the other.

The code will look cleaner if you create the options as a group and then enter the code just once behind the Option Group in the After_Update event. Michelle Fulton

 
I may be thoroughly confused, but I think he/she wants to use an option group for multiple selections...don't think you can do that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top