Reset option buttons to default value

S

Simon

I'm setting up a questionnaire on a worksheet and have assigned pairs
of option buttons as Yes / No to compile answers to a series of
questions. I have 10 pairs of option button on one sheet, each with
their own unique name. The option buttons are Active X.

However only one option button at any time can be checked. Why is
that and what can I do to prevent it? I want one button of each pair
to be checked as an individual works through the questions.

Second related question: At the end of the questionnaire I want to
reset all the option buttons to their default value, which for the Yes
button is False and the No buttons the value is True.

Currently (obWSLQ1Y is one of my option buttons)
obWSLQ1Y.value = True 'works well.

When I try to be smart and reconfigure as a loop the concatenation
doesn't work i.e.
sub Reset
dim i as integer
For i = 1 to 3
obWSLQ &i & Y.value = true
Next

Can you offer some guidance please on how to resolve the
concatenation.

Many thanks

Simon
End sub
 
D

Dave Peterson

Saved from a previous post:

If your optionbuttons are from the Forms toolbar, the put all your optionbuttons
in each group in a groupbox (also on that Forms toolbar).

If your optionbuttons are from the Control Toolbox toolbar, then rightclick on
each optionbutton show the properties (you'll have to be in design mode for
this). Each group should have its own unique groupname.

If you're creating a survey form, you may want to look at Debra Dalgleish's
site:
http://contextures.com/xlForm01.html

================
And to reset those nicely named optionbuttons from the control toolbox toolbar,
you can modify your code like this:

Option Explicit
Sub ResetOptionButtons()

Dim iCtr As Long
Dim wks As Worksheet

Set wks = Worksheets("Sheet1")

For iCtr = 1 To 10
wks.OLEObjects("obWSLQ" & iCtr).Object.Value = False
Next iCtr

End Sub

==========
And a question.

If you're allowing two options per group, why not just use a single checkbox for
each question????
 
S

Simon

Saved from a previous post:

If your optionbuttons are from the Forms toolbar, the put all your optionbuttons
in each group in a groupbox (also on that Forms toolbar).

If your optionbuttons are from the Control Toolbox toolbar, then rightclick on
each optionbutton show the properties (you'll have to be in design mode for
this).  Each group should have its own unique groupname.

If you're creating a survey form, you may want to look at Debra Dalgleish's
site:http://contextures.com/xlForm01.html

================
And to reset those nicely named optionbuttons from the control toolbox toolbar,
you can modify your code like this:

Option Explicit
Sub ResetOptionButtons()

     Dim iCtr As Long
     Dim wks As Worksheet

     Set wks = Worksheets("Sheet1")

     For iCtr = 1 To 10
         wks.OLEObjects("obWSLQ" & iCtr).Object.Value = False
     Next iCtr

End Sub

==========
And a question.

If you're allowing two options per group, why not just use a single checkbox for
each question????

Thanks Dave for your help and tip on Debra's page. I'm glad you like
my nomenclature! obWSLQ1Y = object button Work Station Layout Question
1 Yes.

And a question.
If you're allowing two options per group, why not just use a single checkbox for
each question????
I don't fully understand your question but I want a deafult of No for
each question just so I can tell if somebody has skipped a page of the
questionnaire which is all about computer safety.

Thanks once again.

Simon
 
D

Dave Peterson

If you replaced each pair of optionbuttons with a single checkbox and left it
unchecked, wouldn't that be equivalent as defaulting to the no optionbutton in
the pair?



On 08/16/2010 03:00, Simon wrote:
 

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

Top