Check Box

R

Rich

I have 3 check boxes in a fax cover sheet form, indicating
whether a document will follow by overnight, regular mail
or not be sent.

I have a user form that is used to fill in the information
for the fax cover sheet.

I have 3 option buttons on the user form, one for each
mailing choice. How can I get the option buttons to
connect to the checkboxes (from the Forms toolbar) on my
document?

Thanks for the help
 
J

Jay Freedman

Hi, Rich,

Use code like this in your userform, changing the names of buttons and
checkboxes in the obvious way:

Private Sub CommandButton1_Click()
Dim nSel As Integer

' exactly one of the option buttons will
' have a value of True (= -1)
nSel = -OptionButton1 * 1 - OptionButton2 * 2 - OptionButton3 * 3

With ActiveDocument.FormFields
Select Case nSel
Case 1
.Item("Check1").CheckBox.Value = True
.Item("Check2").CheckBox.Value = False
.Item("Check3").CheckBox.Value = False
Case 2
.Item("Check1").CheckBox.Value = False
.Item("Check2").CheckBox.Value = True
.Item("Check3").CheckBox.Value = False
Case 3
.Item("Check1").CheckBox.Value = False
.Item("Check2").CheckBox.Value = False
.Item("Check3").CheckBox.Value = True
End Select
End With
Unload Me
End Sub

Private Sub UserForm_Initialize()
OptionButton1.Value = True
End Sub

This assumes you've used checkboxes from the Forms toolbar. For this use,
though, you don't need to protect the document for forms -- the checkboxes
will toggle on and off anyway.
 

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