On Thu, 20 Jul 2006 15:32:01 -0700, Lorrie Burns <Lorrie
If the value of an optionbutton from the userform is true, then I need to
make the corresponding checkbox in the MSWord form checked. How do I do this?
Thanks,
Lorrie
You could test them one by one, but that gets tedious. Instead, you
can use the numbers that are at the ends of the field and option
button names by default to handle the correspondence. The trick is to
append a number, which is the current value of the loop counter, to
the "base" part of the name. The resulting string can be used to
address the field or option button within their respective
collections, like this:
Private Sub CommandButton1_Click()
' assumes option buttons and checkbox fields
' share the same number at the end, i.e.,
' OptionButton1 controls Check1 and so on
Dim indx As Integer
For indx = 1 To 3 ' or as many as you need
ActiveDocument.FormFields("Check" & indx).CheckBox.Value _
= Me.Controls("OptionButton" & indx).Value
Next indx
Me.Hide
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.