Option Button Values

T

TomorrowsMan

Thanks for the help yesterday -- greatly appreciated!

So, I'm in the home stretch, but this is proving very hard to track
down, so I'll just outline what I'd like to do.

I have a Word document which is a locked form.

One one page there are 7 criteria for review; each criteria has a set
of 7 option buttons, grouped. They should range in value from 1.0 -
4.0, by half points. The reviewer would select the rating for the
criteria by clicking the option button with the corresponding value.

I know how to set up the option buttons into groups, and I know to keep
them out of the tables because that makes them go all wiggy.

But how do I associate values with the group selection? Inevtiably I
need to calculate the average of the seven rating choices; but for now
I still have to figure out how to get/find the chosen value for each
combo box group.

Thanks!

Chris
 
G

Greg

Chris,

I am assuming that you are using a UserFrom and that each group of 7
options buttons are contained in a frame.

You could use something like this:

Private Sub CommandButton1_Click()
Select Case True
Case Me.OptionButton1
Me.Frame1.Tag = 0.5
Case Me.OptionButton2
Me.Frame1.Tag = 1
'Continue for other 5 OB's
Case Else
MsgBox "Please make a selection"
End Select
Select Case True
Case Me.OptionButton8
Me.Frame1.Tag = 0.5
Case Me.OptionButton9
Me.Frame2.Tag = 1
'Continue for other 5 OB's
Case Else
MsgBox "Please make a selection"
End Select
'Continue for other 5 frames
MsgBox (Val(Me.Frame1.Tag) + Val(Me.Frame2.Tag)) / 2 '7 in your
complete case
End Sub
 
T

TomorrowsMan

Greg,

Thank you.

I just had them on the page in the Word doc, though I'm getting the
impression that a UserForm is the way to go. Thing is, lots of people
here are 'old school,' i.e., still convinced they have to feed cheese
to their mouse. Not the most tech-savvy, shall we say, and as far as
they know a "UserForm" is a "Popup" which obviously must have a "Virus"
and they freak out and call the Help Desk.

I've been reading through and I see other lines of thought with using
check boxes scripted to make one box per group exclusive:

Dim oField As FormField

For Each oField In Selection.Frames(1).Range.FormFields
oField.CheckBox.Value = False
Next oField

Selection.FormFields(1).CheckBox.Value = True

End Sub

(From the word.mvps.org site.)

This seems pretty low-maintenance, but I run up against the same
problem, I'm newbi-gnorant about VBA and have no idea how to A) get the
value for the checked box per group; then B) get it into the
calculations.

I think B will be easy, if I can get help with A......

Cheers,

Chris
 
G

Greg

Chris,

A problem with that method is when users mouse click around the form
rather than using tab.

Each frame containing the buttons will have an index number, you might
use something like:

Sub Test()
Dim oField As FormField
For Each oField In Selection.Frames(1).Range.FormFields
oField.CheckBox.Value = False
Next oField
Selection.FormFields(1).CheckBox.Value = True
Frame1Value
End Sub

Sub Frame1Value()
Dim Val As Double
Select Case True
Case Is =
ActiveDocument.Frames(1).Range.FormFields("Check1").CheckBox.Value
Val = 0.5
Case Is =
ActiveDocument.Frames(1).Range.FormFields("Check2").CheckBox.Value
Val = 1
Case Else
End Select
MsgBox Val
End Sub
 

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