Share via

Word Field Code calculation

Anonymous
2018-01-14T17:23:29+00:00

Hi, I have a word form doc that has two check boxes and I want to assign a value if ticked (box 1 ticked would be 5 and box 2 if ticked 15). In a separate field I want to total the result of the check box selection. So the answer could either be 0, 5, 15 or 20. 

What's the easiest way to do this in word as it's driving me potty.

Thanks in advance.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Paul Edstein 82,861 Reputation points Volunteer Moderator
2018-01-14T22:10:04+00:00

Word field codes cannot perform calculations based on checkbox values. Rather than using checkboxes, you might consider using dropdown formfields with Yes/No answers and their 'calculate on exit' property set in a document will 'filling in forms' protection applied. You could then do the calculation with a formula field coded like:

{={IF{REF Dropdown1}= "Yes" 5 0}+{IF{REF Dropdown1}= "Yes" 15 0} # 0}

Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required.

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-01-16T22:58:09+00:00

    Thanks for the quick response. I had spotted the mistype.

    By adding the Insert Field Chars to the ribbon, it made adding the code much easier.

    Thank you all for your help and assistance.

    I can now sleep tonight. :-)

    Steve

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-01-16T20:52:01+00:00

    Compare what you have tried with the example I posted at https://1drv.ms/w/s!AgOi7jMKouNNnFDZ2vDPD1icPsVe

    You will need to unprotect it before you can see the field coding. Use option-F9/alt-F9/fn-option-F9/fn-alt-F9, depending on your keyboard preferences, to toggle between "field code" view and field results view.

    The other thing that you may need to know is that the result value (0,5,15,20) will not change until you actually click or tab somewhere outside one of the dropdown fields. Just changing the selection from Yes to No or No to Yes isn't enough - that's just the way this type of form works.

    There's a typo in Paul's field code as it stands - one of the "Dropdown1"s needs to be "Dropdown2" - but I assume you picked that up.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2018-01-16T19:50:26+00:00

    Thanks for this. I can use a drop down field instead but still can't get it to work.

    I've used the Insert field option then use the expression builder to add as above and it gives a syntax error. Tried editing but still no joy. 

    There does not seem to be much documentation on this function either.

    Where could I be going wrong?

    Was this answer helpful?

    0 comments No comments