Search code examples
drop-down-menums-wordfieldform-fields

Microsoft Word 2013 - form field - based on dropdown value show / hide fields


I've got several fields in my document . Based on a dropdown-field I want to show / hide several other fields.

Told in another way. I have a dropdown that have these options "Custom", "As sunday", "Closed". If the dropdown value is "custom" then I should show the field "time". All the other options it should just print the dropdown value.

In my word file, it's like this [dropdown] [time]

Ex: dropdown value is "custom", the field should be like below (only showing time):

  • 0800 - 1600

Ex: dropdown value is "closed", the field should be like below (only showing the dropdown value):

  • closed

I've tried to use a formula like this:

{ IF "{dropdown}" = "custom", "", {dropdown} }

I think the problem is that "dropdown" field are changing when a user picks a value from the dropdown. is there a way to insert the value from the dropdown.. like REF "{dropdown}"

If you still don't understand what I'm trying to get.. told in the third way:

  • if the dropdown shows "Custom" I only want to display the time when the store is open.
  • if the dropdown shows anything else but custom it should just print the value of the dropdown, and leave the time "blank"

Solution

  • Assuming that you are using legacy form fields, only trying to change what is displayed, not what fields the user gets to enter (it's ambiguous as far as @"time" is concerned) then you need something like this:

    { IF "{ dropdownfieldname }" = "custom" "{ TIME }" "{ dropdownfieldname }" }
    

    where - all the {} are the special field code brace pairs that you can insert using ctrl-F9 on Windows Word - dropdownfieldname is the name of the drop down field (set in its properties). It is possible to relocate this bookmark name in which case you will need to rename the dropdown a couple of times at develeopment time to re-impose it - "custom" must be "custom" as written in the dropdown's list of values. i.e. if it's "Custom", use "Custom". Or use

    { IF "{ dropdownfieldname \*upper }" = "CUSTOM" "{ TIME }" "{ dropdownfieldname }" }
    
    • { TIME } is the built-in time field. If you really want a reference to another form field value, that happens to have bookmark "time", you will probably need "{ ref time }" instead. If your field is actually called "timefield", use "{ timefield }"

    If you are using Content controls, IMO the best way to do it is actually to create a custom XML part, link the dropdown result to an element in the part, link a plain text content control to the same element, and literally insert that control where I have put { dropdownfieldname }. Ditto for { timefieldm }