Or you can use macros (VBA). There is an admitedly complicated example in my Formfield FAQ on this site. Note to self: got to update that thing. However, there are lots and lots of examples of what you are asking about, if you look hard enough.
"For example: The "benefit band" dropdown - if "6" is selected, then I want the "holiday" field to be "25" and "notice period" to be "1 month".
You do not state if the "holiday" formfield is a text formfield - and please, use proper terms when posting as much as possible. Fields and Formfields are different, and when you talk about one (or the other) is helpful to state one...or the other.
Is "notice period" a text formfield? You do not state if it is, so I am assuming that it is. BTW: it must be really named something else, because you can not have spaces in formfield names.
Code:
Dim DocFF As ActiveDocument.FormFields
Set DocFF = ActiveDocument.FormFields
Select Case DocFF("benefit_band").Result
Case 2 ' or whatever
' do something
Case "yadda" ' or whatever
' do something else
Case 6
DocFF("holiday").Result = "25"
DocFF("notice_period").Result = "1 month"
Case 13456
' do something else
Case Else
' whatever
End Select
If you have a lot of formfields, it is better to use a FormFields - notice the plural - object. That way, you can use:
Code:
DocFF("holiday").Result = "25"
DocFF("notice_period").Result = "1 month"
instead of:
Code:
ActiveDocument.Formfields("holiday").Result = "25"
ActiveDocument.Formfields("notice_period").Result = "1 month"
Just less writing. It also allows faster looping through all the formfields (if this is ever required).
Note: if you are using conditional logic to replace the items in a dropdown formfield, make SURE you clear the entries first! I posted a fairly decent example at VBAExpress ages ago. It comes up if you google "Word formfields conditional logic".
Also, if you google that, there are also multiple examples of using Fields (like the sample post above), that macropod has posted all over the place.
macropod is the leading expert of using Fields in Word, and as we have both mentioned, this is a question that is asked repeatedly. Me, I tend to go the VBA route as I find it clearer to think through - all the possible nested IF statements makes me batty - but there are certainly advantages with using Fields. Not having to deal with possible Security issues for one.
Whether you go the Fields route, or VBA, depends on a clear determination of your requirements.
"A little piece of heaven
without that awkward dying part."
advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)
Gerry