Option Group

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I just created an option group using the wizard (Access 2000) but it's
not working the way I'd like it to. I have 2 options: Member or Affiliate,
with Member as the default. I was a bit confused as to whether to store the
value for later use or store it in a field. I tried to store it to a field,
but then it was bound to the field and couldn't be changed. So I opted to
store it for later.
If I select Affiliate, all seems well. But when I close the form out and
return to the record, the option has switched back to Member. Hmm. Guess I
don't know how to use option groups correctly and would appreciate assistance.
 
Stephanie,

Binding a control doesn't lock it; it just specifies which table column
contains/will contain the data represented by the control's value.

Set the OptionGroup's ControlSource property to the name of a table column.
By doing so, when you save the record (for example, Affiliate), that value
will be stored. When you return to that record, Affiliate will be selected.
If it doesn't, come back here and we'll start troubleshooting.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Graham,

Thanks. I'm wondering if I'm using options correctly. I was just using the
Member field as a yes/no. I have many reports that have a Member=yes
condition. Now I want the choice of being a Member or an Affiliate, but I
need yes/no as well. So when I tried to store in a field, my choice was
Member or Affiliate field with a 1,2 value not yes/no. So I don't have one
field with 2 different values, I seem to have 2 fields, each with 2 values.

Will an option group work for me or do I need to do something else? Could I
use an option group and then have reports filtered on Member=1, Affiliate=2?
Would I still have two separate fields? Thanks.

Graham R Seach said:
Stephanie,

Binding a control doesn't lock it; it just specifies which table column
contains/will contain the data represented by the control's value.

Set the OptionGroup's ControlSource property to the name of a table column.
By doing so, when you save the record (for example, Affiliate), that value
will be stored. When you return to that record, Affiliate will be selected.
If it doesn't, come back here and we'll start troubleshooting.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Stephanie,

If someone can be either a Member OR Affiliate, then you have several
options:

1. Put two OptionBoxes inside an OptionGroup, and bind the OptionGroup,
thereby allowing you to store a value of 1 or 2.

2. Use a single CheckBox whose Label changes according to its value (ie:
"Member" if True, and "Affiliate" if False).

But, if you want to store a True/False value for each of the two Checkboxes
(chkMember and chkAffiliate), AND if you want that exclusive OR
functionality (where only one of them can be checked at any time), then use
Option 1 above, but don't bind the OptionGroup - bind each OptionBox
instead.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Stephanie said:
Graham,

Thanks. I'm wondering if I'm using options correctly. I was just using
the
Member field as a yes/no. I have many reports that have a Member=yes
condition. Now I want the choice of being a Member or an Affiliate, but I
need yes/no as well. So when I tried to store in a field, my choice was
Member or Affiliate field with a 1,2 value not yes/no. So I don't have one
field with 2 different values, I seem to have 2 fields, each with 2
values.

Will an option group work for me or do I need to do something else? Could
I
use an option group and then have reports filtered on Member=1,
Affiliate=2?
Would I still have two separate fields? Thanks.
 
Graham,
Thanks. I like the last version you described- not
binding the OptionGroup, but each OptionBox instead.
Except I'm not sure how to do that.
I created the OptionGroup using the wizard and didn't bind
it. When I look at the properties of the OptionBoxes it
shows me that the Option Value is 1 or 2 respectively.
But I can't figure out where to bind the Member option box
to the Member field, and the Affiliate option box to the
Affiliate field so that the value of each option box is
Y/N. I appreciate your efforts!
 
Stephanie,

To use my second suggestion - Using a single CheckBox whose Label changes
according to its value (ie: "Member" if True, and "Affiliate" if False).

1. Open the form in design view, and display the Properties box.

2. Add a CheckBox (NOT an OptionBox) to the form (without using the Wizard).

3. Set its DefaultValue property to "True".

3. Change its label's text to "Member (if ticked)" (for the purpose of this
example, we'll make that the default).

4. Add the following code to its Click() event:
Private Sub Check13_Click()
Me!Check13.Controls(0).Caption = _
IIf(Me!Check13 = True, "Member (if ticked)", "Affiliate (if not
ticked)")
End Sub

5. Of course, your CheckBox will not be named "Check13". Change the above
code to suit the name you gave your CheckBox.

6. Bind the CheckBox to a single field in the underlying table. It will be
Member if True (-1), and Affiliate if False (0).

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Graham,
I'm sorry- I wanted to try this:

1. Put two OptionBoxes inside an OptionGroup, and bind
the OptionGroup, thereby allowing me to store a value of 1
or 2. Except I want to store a True/False value for each
of the two Checkboxes (chkMember and chkAffiliate), AND I
want that exclusive OR functionality (where only one of
them can be checked at any time), so I want to use
Option 1 above, but don't bind the OptionGroup - bind
each OptionBox instead.

So I'd use the wizard to create the OptionGroup and "store
the value for later use". The wizard will also create the
2 OptionBoxes with a value of 1 or 2. So I have
OptionBoxes (either radial or a check box format but not
the CheckBoxes that I'd get from dragging the actual field
to the form from the field list). It's the binding of
each OptionBox that I don't understand. Is that something
that I need to do on the table? Do I need to do something
with each OptionBox property?

Thanks for your patience!
Stephanie
 
Stephenie,

Sorry, I obviously misunderstood.

You want to have the 2 OptionButtons inside the OptionGroup, bind the
OptionGroup, store True/False for each OptionBox, and have exclusive OR
functionality.

The question that immediately comes to mind is - if you want to bind the
OptionGroup AND store True/False values for each OptionButton, where do you
intend to store the True/False values?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Stephenie,

OK, I just re-read your last response. I see you don't want to bind the
OptionGroup.

1. Put 2 OptionBoxes on the form, call then (for example) "Option1" and
"Option2".

2. Add an OptionGroup to the form, and set its label to whatever you like.

3. Drag the two OptionButtons onto the OptionGroup, to give the appearance
that the OptionGroup is their container.

4. Add the following to Option1's Click event:
Me!Option2 = Not Me!Option1

4. Add the following to Option2's Click event:
Me!Option1 = Not Me!Option2

5. Set the ControlSource for each OptionButton to point to the table field
where you want their values stored.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Thanks! I'm just headed out on vacation- I'll be able to
give it a try but don't know if I'll have internet
access. If I still can't figure it out, I'll start a new
post or give up ;)
Cheers,
Stephanie
 
Stephanie,

No, don't give up! If you can't find this thread when you return, just start
another.

Enjoy your vacation. :-)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
Back
Top