Question Add checkbox to option group afterwards

Jerome

Registered User.
Local time
Today, 06:27
Joined
Jul 21, 2009
Messages
77
Hello,

I've created a option group in my form. I've added some checkboxed into it using the control wizzard. Now I would like to add some more checkboxes to the option group.

I can create them outside the option group and dragged it into it but when I run this code:

Code:
For Each Control In Me.FrmTest.Controls
    If TypeOf Control Is CheckBox Then
    MsgBox Control.Name
    End If
Next
The added checkbox is not seen within the option group? How can I do this?

Thanks in advance.
 
Last edited:
I was just reading through Access help and happened across this:

Ways to create an option group
By default, all OptionButton controls on a container (such as a form, a MultiPage, or a Frame) are part of a single option group. This means that selecting one of the buttons automatically sets all other option buttons on the form to False.

If you want more than one option group on the form, there are two ways to create additional groups:

I think this bit may be of interest
Use the GroupName property to identify related buttons.
Put related buttons in a Frame on the form.

The first method is recommended over the second because it reduces the number of controls required in the application. This reduces the disk space required for your application and can improve the performance of your application as well.
 
the way an option group woirks is that you have a box (the group) in which you store a number of option buttons. these are radio buttons ONLY - ie, only 1 can be selected at any time.

each button has a value, normally 1,2,3,4 etc

you dont code the buttons individually - the sleected item is returned by the value of the option group (ie - the frame, if you like) itself - usually using the aftetupdate event of the frame to respond to the selection made

you cant add other controls inside the option group (other than more radio buttons!)
 
An option group can have option buttons, check boxes or toggle buttons. My guess is you can’t have a mixture, but I wouldn’t be surprised if you could have a mixture. Would be well worth checking out.
 
Ok, after studying the option group a bit more I came to the conclusion this is not what I want.

I want to set the checkbox value true or false, this is not possible with the option group.

Is there another way to put/assign check boxes inside a frame so I can control the check boxes using this code? This because I have a lot of checkboxes on the form.

Code:
dim Ctrl as control
For Each Ctrl In Me.FrmTest.Controls
'MsgBox Control.Name
    If TypeOf Ctrl Is CheckBox Then
    MsgBox Ctrl.Name
    Ctrl.Value = true
    End If
Next
 
When I click the link I have to sign up?
 
The problem is I have a lot of checkboxes on my form but only want to use the for next on a selection of these checkboxes.
 
The problem is I have a lot of checkboxes on my form but only want to use the for next on a selection of these checkboxes.

The thread I directed you to has various ideas for handling multiple controls, it also has ideas for handling smaller groups of controls, individual groups on a form, for example you can add something in the controls tag property to identify it, alternatively you can name the controls in a particular way and use that. It’s all there in that thread, read the thread and then come back here with a sensible question.
 
dont have an option group

just have a rectangle, and group them together. however there is no way of directly saying

for each .. next with a group of controls

however - if you have a naming convention then you can get at them like this

Code:
for x = 1 to 4
  msgbox(me.controls("mybox" & x).name)
next
 

Users who are viewing this thread

Back
Top Bottom