View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ed
 
Posts: n/a
Default Supress blank lines

Hi Jan,

What about some logic like:

IF P1 "0.00" display P1
IF P1 "0.00" AND P2 "0.00" display P2
and so on up to P5
IF SP_P1 "0.00" display SP_P1
IF SP_P1 "0.00" AND SP_P2 "0.00" display SP_P2
IF SP_P1 "0.00" AND SP_P2 "0.00" AND SP_P3 "0.00" display
SP_P3

That is, display any PAID value which is not "0.00" and all of whose
preceding PAID values are not "0.00", and display any SP_PAID value
which is not "0.00" and all of whose preceding SP_PAID values are not
"0.00".

In terms of IF fields, the P1 field would involve no nesting, the P2
field would nest the P2 test inside the TrueText of the P1 test, the
P3 field would nest the P3 test inside the TrueText of the P2 test
which would itself be nested inside the TrueText of the P1 test, and
so on. The SP* test would start from a simple non-nested one and
follow the same pattern.

One method that I find useful when I have to work with merge fields
involving a lot of nesting is to avoid using merge fields to start
with and use SET fields instead. I got this tip from one of Peter
Jamieson's replies to one of my questions some time ago. I might use a
block of SET field such as { SET P1 "10" } and then construct the IF
logic by testing the values of these fields - e.g. { IF { P1 }
"0.00" "{ P1 }" }. That way I don't have to actually mailmerge to test
the logic, I can just update the fields and display the field results,
and I don't have "MERGEFIELD" cluttering up the logic while I am
trying to get it to work. Once it works I can find and replace (for
example) "P" with "MERGEFIELD PAID".

Another thing that can make constructing nested IF fields easier than
it might be when you are essentially nesting the same type of test
over and over is to create the basic non-nested field such as

{ IF { P1 } "0.00" "" }

In this case I am going to repeatedly nest into the TrueText part of
my fields so I have left that part empty.

To create the first level of nesting I copy and paste the basic field
and then just paste it again into the relevant TrueText to get

{ IF { P1 } "0.00" "{ IF { P1 } "0.00" "" }" }

I repeat this procedure for as many levels of nesting as are required.

{ IF { P1 } "0.00" "{ IF { P1 } "0.00" "{ IF { P1 } "0.00"
"" }" }" }

Each time just pasting into the TrueText.

Once I've got all of them I just go from the top and replace "P1" with
"P2", "P3" etc. as appropriate and put into each of the final
TrueTexts whatever it is I want to be displayed. Just having to paste
the same thing into (in this case) the TrueText for as many levels of
nesting as I want makes it very easy to get the nesting right. Once
the nesting is right I can easily make the required substitutions.

When you have IF fields on several lines you may end up with blank
lines for those tests that don't display anything. The blank lines
result from the paragraph marks which follow the IF fields. The way to
get rid of them is to make the "display" of the paragraph marks
conditional upon there being some data to display on the relevant
line. I.e. you in effect move the paragraph marks from outside the
field to just inside the closing quotes of the relevant TrueText. I
find it useful to leave the blank lines issue at bay until I have
sorted out the logic. Once the logic is working on separate lines I
can just insert a paragraph mark inside the closing quotes of each of
the relevant TrueTexts and then (in a second pass) delete the
(unwanted) paragraph marks from outside the fields.

Hope this makes sense.

Cheers.

Ed


Jan" wrote in message
...
The data source is a .csv file we receive for a merge form letter.

It
contains $0.00 in any amount field when no $$$ exist. The data from

up to 10
columns are placed in rows within a text box. (See below). I need

to supress
all lines when $0.00 exists. For example: PAID1 = $50, PAID2 = $25,

PAID3 =
$0.00, PAID4 = $0.00, PAID5 = $0.00, SP_PAID1 = $100, SP_PAID2 =

$0.00,
SP_PAID3 = $0.00 - we can only show three rows (PAID1, PAID2,

SP_PAID1) with
SPPAID1 directly underneath PAID2. I have tried if...then

statements,
switches, and a variety of options with no success in removing rows

with
$0.00. Any help would be appreciated. Thank you.

{MERGEFIELD "PAID1"}
{MERGEFIELD "PAID2"}
{MERGEFIELD "PAID3"}
{MERGEFIELD "PAID4"}
{MERGEFIELD "PAID5"}
{MERGEFIELD "SP_PAID1"}
{MERGEFIELD "SP_PAID2"}
{MERGEFIELD "SP_PAID3"}