View Single Post
  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
 
Posts: n/a
Default If then else question

You still need the If...then...Else... fields to check for data in Name2,
Name3, Name4 and Name5. If there is not data insert nothing, if there is
data, insert that data preceeded by whatever it is that you want to separate
it from the previous item.

The construction will be

{ MERGEFIELD Name1 }, { MERGEFIELD Name1Description }{ IF { MERGEFIELD
Name2 } = "" "" "; { MERGEFIELD Name2 }, { MERGEFIELD
Name2Description }" }{IF { MERGEFIELD Name3 } = "" "" "; { MERGEFIELD
Name3 }, { MERGEFIELD Name3Description }" }{IF { MERGEFIELD Name4 } = "" ""
"; { MERGEFIELD Name4 }, { MERGEFIELD Name4Description }" }(IF { MERGEFIELD
Name5 } = "" "" "; { MERGEFIELD Name5 }, { MERGEFIELD Name5Description }" },
and

Note that there is no space between the } and the { IF

--
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

"Michelle" wrote in message
...
No, unfortunately, they are not uneeded:

Here's what I have as merge codes (and I will add ", and" per your
suggestion):

Name1, Name1description Name2, Name2 description Name3 Name3,
description Name4, Name4 description Name 5, Name 5 description, and

This works fine if indeed 5 names are merged. But if any less than 5 are
merged, there are spaces before ", and".

So if there is only one name in the record, the result is:
JOHN SMITH, an individual , and

That's why the ", and" needs to be in the mergecode.

Hope this is clear and that you have a solution.

"Doug Robbins - Word MVP" wrote:

You must have some uneeded spaces in the field construction some where.

--
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