How to create mutually exclusive checkboxes inside a Table

S

Strobo

Hi,

I'm creating a checklist containing a large table with a set of 3 or 4
mutually exclusive check boxes in each row of the last column.
At first I tried using control check boxes, but it seems that there is no
simple way to make them mutually exclusive. I would have to write individual
code for each check box and with a large number of check boxes this becomes
too complicated.

I then switched to form check boxes, by adding the set of check boxes into a
form, and then copying that form. It was then as simple as having a simple
Macro that would run on entry.

The problem is that it seems that this does not work once the form is placed
inside a table.

Can anyone suggest how can I go about this?
 
S

Strobo

Ok,

So I got this to work somehow after days of trying, and 5 min after posting
the question.

Sub TBLCheckBoxesExclusive()
Selection.Rows(1).Range.FormFields(1).Result = False
Selection.Rows(1).Range.FormFields(2).Result = False
Selection.Rows(1).Range.FormFields(3).Result = False
Selection.FormFields(1).CheckBox.Value = True
End Sub

Now I have a different problem.
How do I count the checkboxes.
In particular, checkboxes correspond to Pass, Fail and N/T and I would like
to count how many of each are checked.

Looking at the existing code, I would make a loop that goes through each
cell and checks the Result property of each, FormFields(1), (2) and (3).
I am having trouble making this loop though.

I tried something like this to count all the 'Pass'

Dim oRow as Row
Dim chksPass as Integer

For Each oRow In Selection.Tables(1).Rows
If oRow.Range.FormFields(1).Result = True Then
chksPass = chksPass + 1
End If
Next oRow

This does not work though.

Any ideas?
 
D

Doug Robbins - Word MVP on news.microsoft.com

Instead of using the .Result of the FormField, use .CheckBox.Value

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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