View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor
 
Posts: n/a
Default Conditional Merge Problem

It works for me as you have it written - assuming § is your bullet
character.

{ IF{ Mergefield Field1 } "" "§ Value of Field1 is { Mergefield Field1 }
" }{ IF{ Mergefield Field2 } "" "§ Text for Field2
" }{ IF{ Mergefield Field3 } "" "§ Text for Field3
" }{ IF{ Mergefield Field4} "" "§ Text for Field4 is { Mergefield
Field4 }
" }

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Tom Bean wrote:
I am trying to create a document containing up to 30 items in a
bulleted list based on the value of MERGEFIELDs corresponding to each
item but am having problems getting the merge to work correctly.

An example of the list in my current document is:

{ IF { MERGEFIELD Field1 } "" "§ Value of Field1 is { MERGEFIELD
Field1 }Enter
" }{ IF { MERGEFIELD Field2 } "" "§ Text for Field2Enter
" }{ IF { MERGEFIELD Field3 } "" "§ Text for Field3Enter
" }{ IF { MERGEFIELD Field4 } "" "§ Value of Field4 is {
MERGEFIELD Field4 }Enter
" }Enter

where Enter indicates where the 'Enter' key is pressed resulting in
a paragraph mark.

I want the document merged using the above example to look like:

§ Value of Field1 is Value1
§ Text for Field2
§ Value of Field4 is Value4

where the data source has "Value1", "Y", "" and "Value4" in Field1,
Field2, Field3 and Field4 columns.

The first problem I encountered was with Bullets showing a blank line
if the condition was not True, hence the square symbol at the
beginning of the text.

After replacing Bullets with the square symbol, everything appeared
to work when all the merge fields had non-empty values. When the
value for Field3 was empty, as in the above example, neither the line
for Field3 or Field4 were displayed. From various data patterns I
tried, the output stopped when the first empty column was encountered.

Thinking the empty columns might be the problem, I tried putting "N"
for the value of the fields I didn't want displayed and changed the
IF statement to IF { MERGEFIELD Field1 } "N". Once again this
resulted in unexpected behavior, all the lines were displayed
regardless of whether on not they contained an "N" and after the
first "N" was encountered, the values for subsequent fields was not
shown.
Obviously, I'm doing something wrong.

Can someone please tell me how to do this correctly?

Thanks,
Tom