Form fields: IF (checkbox)?

M

Mike

I'm creating a word form, and need a field to be calculated differently
depending whether a checkbox is checked or not. I can't seem to get it
working. Here's what I've done:

I created three fields, a checkbox called "checkbox", and two number
fields called "initial" and "final". The user will enter a number in
"initial". If they check "checkbox", then "final" should be half of
"initial", otherwise it should equal "initial".

I set up "final" as a calculate field, with the following formula:

=IF (checkbox=true,initial/2,initial)

But, regardless of if the checkbox is checked or not, "final" always
winds up equalling "initial". Can you please tell me what needs to go
in the formula field to consider the state of the checkbox?

Thanks!
 
D

Doug Robbins - Word MVP

I don't think that you can do that with a calculation type checkbox (at
least I could not get it to work). You can however do it by having the
following macro run on exit from the Initial formfield and the checkbox
formfield with the Final formfield just set to a text type formfield

Dim Divisor as Long
If ActiveDocument.FormFields("check1").CheckBox.Value = True Then
Divisor = 2
Else
Divisor = 1
End If
ActiveDocument.FormFields("Final").result =
ActiveDocument.FormFields("Initial").result / Divisor


--
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
 
M

macropod

Hi Mike,

You can't use formfield checkbox states in other fields. As a workaround,
you could test for a Yes/No answer in a drop-down box (eg {IF{Dropdown1}=
"Yes" {=Initial/2} {Initial}})
where the braces (i.e. '{}') are created in pairs via Ctrl-F9. Note the
syntax and spacing.

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