manipulating "option" buttons in code...

  • Thread starter Thread starter Brad Pears
  • Start date Start date
B

Brad Pears

Ok, I am going nuts with this... I have several option buttons within a
frame so that as you select one option, any other selected option button is
now not selected etc..

There is an instance where I want to programatically set a partular option
button. What is the syntax for doing this from code? I have tried several
things but have been unsuccessful at making the option button "turn on" from
code...

Thanks,

Brad
 
This should make Button Two selected if Button One get's selected.

Private Sub ButtonOne_AfterUpdate()
If Me.[ButtonOne].Value = True Then
Me.[ButtonTwo].Value = True

End If
End Sub
 
Brad,

Not sure what action you are going to use to set the value, but you just set
the value of the option group to the value of the option you want selected:

Me.NameOfOptionGroup = 2

This would select the option with the value of 2.
 
Ok, I am going nuts with this... I have several option buttons within a
frame so that as you select one option, any other selected option button is
now not selected etc..

There is an instance where I want to programatically set a partular option
button. What is the syntax for doing this from code? I have tried several
things but have been unsuccessful at making the option button "turn on" from
code...

Thanks,

Brad

The value of the 0ption button determines the value of the Option
Group, and the value of the group will turn on the individual button.

So, for example, if you want to give a group a certain value if a
criteria is met, code:
If [LastName] = "Smith" then
OptionGroupName = 3
Elseif [LastName] = "Jones" Then
OptionGroupName = 2
Else
OptionGroupName = 1
End If

The individual buttons within the group will 'turn on'.
 
Here's my way of doing this.

Give each option control a meaningful name; eg. optThis, optThat,
optTheOther.

Then, if the name of the option group control is grpWhatever, here is
how you select the optThat option:

me![grpWhatever] = me![optThat].OptionValue

It's a bit more typing, but it's more readable & self-explanatory IMHO.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top