Supress blank lines

J

Jan

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"}
 
G

Graham Mayor

You ned a string of conditional fields each following the previous on the
same line, with the line breaks included as part of the result.

{ IF{ MERGEFIELD PAID1 } <> "$0.00" "{ MERGEFIELD PAID1 }
" }{ IF{ MERGEFIELD PAID2 } <> "$0.00" "{ MERGEFIELD PAID2 }
" }{ IF{ MERGEFIELD PAID3 } <> "$0.00" "{ MERGEFIELD PAID3 }
" }{ IF{ MERGEFIELD PAID4 } <> "$0.00" "{ MERGEFIELD PAID4 }
" }{ IF{ MERGEFIELD PAID5 } <> "$0.00" "{ MERGEFIELD PAID5 }
" }{ IF{ MERGEFIELD SP_PAID1 } <> "$0.00" "{ MERGEFIELD SP_PAID1 }
" }{ IF{ MERGEFIELD SP_PAID2 } <> "$0.00" "{ MERGEFIELD SP_PAID2 }
" }{ IF{ MERGEFIELD SP_PAID3 } <> "$0.00" "{ MERGEFIELD SP_PAID3 }
" }

Text boxes are not the greatest plan and will not grow or shrink to
accommodate the text. I would use a table cell or a frame with auto height
setting.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jan

Graham, I appreciate your reply very much. I have tried this, however I
believe that after the first PAID1 is true (PAID1 <> $0.00), the calculation
ends and the 'Then' (which contains the rest of the nested If...Then
statements) is ignored causing the remaining PAID2, PAID3 to be mute.
When I tried this without nesting the If...Then statements together,
{IF {MERGEFIELD PAID1} <> "$0.00" "{MERGEFIELD PAID1} " "} and just
used them in a straight column, the mergefields that did = $0.00 placed a
space in the line, causing the blank lines to remain and not supress
together. I believe I need a way when the condition = $0.00 a null results.

I also appreciate your comment on the text box vs table frame. The data in
this form can not grow or shrink outside the area it's given - the reason for
using the text box.

Thank you again,
Jan
 
E

Ed

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
 
G

Graham Mayor

The fields are not nested, they are separate and evaluated individually
based on the content of the fields. There is no 'Then' involved. If the
field does not contain $0.00 the response is to insert a line break and the
field. If it contains $0.00 it does nothing. Your interpretation of this
does not include the line break.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jan

Graham,
Thank you for sticking with me. I interpreted your example as using the
If..then statement because I didn't see the double quotes following the line
break/single quote, which are put in automatically using the Toolbar 'Insert
Word Field' options - in the If...Then option. I have tested this and found
it works both with or without the double quote then portion, as long as the
line break is in the correct position.
I have enjoyed learning something new and again, appreciate your help.
Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top