how to suppress a line having a nil or zero value in a merge file

how to suppress a line having a nil or zero value in a merge file

Post by TWFydGl » Fri, 21 Apr 2006 09:00:01


I need to know how to suppress a line if the merge field value is zero
 
 
 

how to suppress a line having a nil or zero value in a merge file

Post by Peter Jami » Fri, 21 Apr 2006 17:14:23

If the value is null, i.e. { MERGEFIELD myfield } displays no text, then

{ MERGEFIELD myfield }

on its own in an otherwise blank line should result in a suppressed line,
assuming that "suppress blank lines" is swithced on, which it is by default
in Word 2002/2003,

If the value is 0, things are harder. If you have a field in your data
source which is always blank, you can use

{ IF { MERGEFIELD myfield } = 0 "" "{ MERGEFIELD myfield }" }{ MERGEFIELD
myblankfield }

Word will /not/ suppress the line if it is blank because of the result of
the IF field:

{ IF { MERGEFIELD myfield } = 0 "" "{ MERGEFIELD myfield }" }

even if you try:

{ IF { MERGEFIELD myfield } = 0 ""{ MERGEFIELD myblankfield}" "{ MERGEFIELD
myfield }" }

Finally, in Word 2002/2003, Word will not suppress these blank lines if they
are nested inside another field such as an IF or INCLUDETEXT. Your only
option then is to use an IF to generate a new paragraph when the field is
/not/ blank or 0, e.g.


{ IF "{ MERGEFIELD myfield }" = "" ""
"{ IF { MERGEFIELD myfield } = 0 ""
"{ MERGEFIELD myfield }
" }

(There needs to be a new paragraph before the final double-quote mark)

Peter Jamieson