How to add up check box forms.

C

ClassMan

I will try to give as much info as possible of my problem...

We have a forms document that has numbers beside check boxes (eg. a check
box for all 7 points on a likert scale). A question is asked the the user
checks a box next to a 1 - 7.

I want to add up a check box next to a "seven" with several other questions
on the survey... Giving me a sum of check box values in another place.

My question is is it possible to assigne values to check boxes then cross
reference them to another field. This other field will need to be
dynamically summing the totals (eg. a person changed their mind etc.)

Hope that's enough info, the main question is how to assign values to check
boxes and sum in another place. I am using "cross reference" else where in
the document to auto-populate can I do it here to?
 
S

Stephanie Krieger

Hi,

The easiest thing to do here is to write a macro and have
that macro run on entry and exit from every applicable
check box.

Word reads check box values as True\False -- but based on
whether the value is true or false, you can conditionally
assign a value to that check box for just within the
macro.

The macro adds the value of the check box to your total
only if the box is checked. One line of code at the end
of the macro identifies that sum as the value of your
other form field (presumably a text form field). By
running it on entry and exit of each check box, it
dynamically updates the text form field with the new
value whenever a check box's value is changed. Below is
a sample of the code, where "c1" through "c7" are the
bookmark names associated with each of 7 check boxes,
and "t1" is the bookmark name associated with the text
form field where the sum should appear.

Note that you can customize the bookmark name of a field,
as well as set the macro to run on entry and exit, within
each field's Properties dialog box.

Also note that your best bet is to create a Module within
the form document itself to store this macro code.
Here's the sample code:


Sub addchecks()

Counter = 0
With ActiveDocument
If .FormFields("c1").Result = True Then
Counter = Counter + 1
End If
If .FormFields("c2").Result = True Then
Counter = Counter + 2
End If
If .FormFields("c3").Result = True Then
Counter = Counter + 3
End If
If .FormFields("c4").Result = True Then
Counter = Counter + 4
End If
If .FormFields("c5").Result = True Then
Counter = Counter + 5
End If
If .FormFields("c6").Result = True Then
Counter = Counter + 6
End If
If .FormFields("c7").Result = True Then
Counter = Counter + 7
End If

..FormFields("t1").Result = Counter

End With

End Sub


The only imperfection in this is that, because the most
dynamic this method can be is to run on entry and exit of
each check box, if someone checks a box and then unchecks
the same one before moving to another field, the total
will not update to reflect the unchecking immediately.
Instead, the total will update the next time the user
goes to any other field in the document(that is, on
exiting the active field).

Hope that's helpful.

Best,
Stephanie Krieger
author of Microsoft Office Document Designer (from
Microsoft Learning)
email: MODD_2003 at msn dot com
blog: arouet.net
 
B

BigWylie1

HI Stephanie,
I have a similar problem with smaller requirements.
I read your reply but I am still unclear.
I have tried to follow your format x times( embarassed) but cant get it right
Syntax errors.

Please read string: WORD TABLE FORMULAS posted today?

I have a field in a separate table but want to have a result returned if a
bookmarked checkbox 'OPTION1'=True, result =$59.99 or if false, then
Option2 checkbox=True, Result ='$100.00'

can you understand this message?

Clearer description:
I am creating a contract. The user will either select Option 1@ $59.99 or
Option 2 @$100.00.
Tn a separate table ( Calculation ) I have a cell that I would like to
return either $59.99 or $100.00 based on the users selected check box
bookmark (either OPTION1 OR OPTION2).

Maybe this is clearer?
 

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