Word fill in form

J

jlo

I inherited a Word fill-in form. I was told the yes and no check boxes were
not working correctly. Instead of just using the yes, no check boxes, the
user wanted the person who fills out the form to only select yes or no. If
you select no, yes would be unchecked. I found a macro in the Macros dialog
box.

Sub MakeCheckBoxesExclusive()
'
' MakeCheckBoxesExclusive Macro
'
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
 
G

Graham Mayor

A slightly more clunky method that works is to run a macro on exit from each
of the check box fields and set the other accordingly. The following assumes
two check box fields each with its own macro:

Sub is1Checked()
With ActiveDocument
If .FormFields("Check1").CheckBox.Value = True Then
.FormFields("Check2").CheckBox.Value = False
End If
If .FormFields("Check1").CheckBox.Value = False Then
.FormFields("Check2").CheckBox.Value = True
End If
End With
End Sub

Sub is2Checked()
With ActiveDocument
If .FormFields("Check2").CheckBox.Value = True Then
.FormFields("Check1").CheckBox.Value = False
End If
If .FormFields("Check2").CheckBox.Value = False Then
.FormFields("Check1").CheckBox.Value = True
End If
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi jlo,

If the user wants only Yes or No to be possible, why not use a dropdown in which 'Yes' and 'No' are the only options? Seems like a
lot less bother to me.

Cheers
 

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