View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail Merge: If ... then ... else

Yes. It's generally easier to insert this kind of "nested field" using the
keyboard rather than the drop down lists and so on - you need
a. to enable the Mail Merge toolbar (View|Toolbars in WOrd 2002,2003, it
automatically appears for mailmerge documents in earlier versions) Use the
button to switch between "field view" where you see fieldname and
"data preview" where you see some result data
b. Alt-F9 to toggle between "field code view" where you see { MERGEFIELD
fieldname } and "field view"/preview. You may find that fields disappear as
you insert them and you need to use Alt-F9 to get them back.
c. select one or more fields and press F9 to update their values
d. ctrl-F9 to insert /each/ pair of the special "field code braces"

The field you need is

{ IF "{ MERGEFIELD field1 }" = "" "{ MERGEFIELD field2 }" "{ MERGEFIELD
field3 }" }

If you don't like all the quotes in this case you can probably get away with

{ IF { MERGEFIELD field1 } = "" { MERGEFIELD field2 } { MERGEFIELD
field3 } }

but I advise you to stick with what I suggested.

If the field name "field1" actually has spaces in it, e.g. is "field 1",
then you need even more quotes to surround the name, e.g.

{ IF "{ MERGEFIELD "field 1" }" = "" "{ MERGEFIELD field2 }" "{ MERGEFIELD
field3 }" }

Peter Jamieson

"Mark Parent" wrote in message
...
I understand that I can use this function to check a field in my merge
data,
and insert one or another text string into my Word document. What I'd
like
to do is use a field in my merge data to direct which of two merge fields
to
print. Is there a way to implement something like:
If [FIELD1] is Empty then [FIELD2] else [FIELD3] ?