Creating Paragraph Breaks within Conditional Field Codes

I'm trying to create a sequential list using field codes and mail merge. My problem is that certain items do not need to appear on the list, depending on how the mail merge goes. This is confusing, so I will give an example.

Let's say I'm putting together a list of quantities for various fruits. I've got a mail merge document that tells me how many apples, oranges, and pears I have. So the list might look like:

1. There are 32 apples.

2. There are 27 oranges.

3. There are 3 pears.

Using field codes it looks more like:

(SEQ list1) There are (MERGEFIELD "Apples") apples.

(SEQ list1) There are (MERGEFIELD "Oranges") oranges.

(SEQ list 1) There are (MERGEFIELD "Pears") pears.

Now, if there are no oranges, I don't want it to be on the list at all. I just want the list to look this this:

1. There are 32 apples.

2. There are 3 pears.

To do this, I use if/then conditioning. (IF (MERGEFIELD Oranges) = 0 "" "(SEQ list1) There are (MERGEFIELD "Apples") apples. This is successful in removing the oranges from the list, but there remains a space:

1. There are 32 apples.

2. There are 3 pears.

I've tried every which way I can thing to get rid of that space, but I can't figure it out. Perhaps someone here could help me.

Answer
Answer

What you need is something more like this:

{ IF { MERGEFIELD "Apples" } > 0 "{ SEQ list1}. There are { MERGEFIELD "Apples" } apples.

" }{ IF { MERGEFIELD "Oranges" } > 0 "{ SEQ list1}. There are { MERGEFIELD "Oranges" } oranges.

" }{ IF { MERGEFIELD "Pears" } > 0 "{ SEQ list1}. There are { MERGEFIELD "Pears" } pears.

" }

That is, the paragraph break must be inside the TrueText so that it (along with the rest of the numbered item) does not appear if the condition is not met.

Microsoft MVP (Word) since 1999
Fairhope, Alabama USA
http://ssbarnhill.com
http://wordfaqs.ssbarnhill.com
Screen shots captured with TechSmith's Snagit

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 356 Applies to: