Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form fields: IF (checkbox)?
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! |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form fields: IF (checkbox)?
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 "Mike" wrote in message oups.com... 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! |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Form fields: IF (checkbox)?
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 "Mike" wrote in message oups.com... 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! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to create listbox and checkbox in Word form | Microsoft Word Help | |||
Mail Merge and checkbox form fields | Mailmerge | |||
mail merge and text form fields | Mailmerge | |||
Default text shown in form fields | Microsoft Word Help | |||
Hyperlink macro assigned to checkbox form field | Microsoft Word Help |