Microsoft KB Archive/264787

= Blank line is not suppressed in a conditional mail merge =

Article ID: 264787

Article Last Modified on 1/27/2007

-

APPLIES TO


 * Microsoft Word 97 Standard Edition

-



This article was previously published under Q264787





SUMMARY
By default, Microsoft Word suppresses blank lines in a mail merge when the result of a MERGEFIELD is blank.

However, when you perform a conditional mail merge, the result of a conditional field may be blank. This causes an extra blank line.

For example, in a mail merge, you may want to display a special message for residents of a particular state and not display that message to residents of other states. You might create a letter main document that looks similar to the following example:

{MERGEFIELDNAME}

{MERGEFIELDADDRESS1}

{MERGEFIELDCITY},{MERGEFIELDSTATE}{MERGEFIELDPOSTALCODE}

Dear{MERGEFIELDNAME},

{IF{MERGEFIELDSTATE}=&quot;WA&quot;&quot;ForWashingtonstateresidents, weofferspecialratestoAsia.&quot;}



When you perform the merge, the merged document for a resident of Washington state may appear correctly as the following:

Name

Address

City,StatePostalCode

DearName,

ForWashingtonstateresidents,weofferspecialratestoAsia.



But the merged document for a resident of a different state may appear as the following:

Name

Address

City,StatePostalCode

DearName,



The result for a non-Washington state resident is additional space (blank lines) between the greeting and the body of the letter.

This article demonstrates how to use an IF field as a conditional statement to evaluate the results of the field and suppress the line, if the result is blank.



MORE INFORMATION
This article provides two examples of how to use a conditional statement to suppress the extra line when the result is blank. Use the following examples as appropriate in your situation.

Example 1
To correct the problem as described in the &quot;Summary&quot; section of this article, use an IF field as a conditional statement that compares whether a MERGEFIELD meets a certain value, as in the following example:

{IF{MERGEFIELD}=&quot; &quot;&quot;True&quot;&quot;False&quot;}

This conditional IF field states that if the MERGEFIELD is equal to, do the True part; otherwise, do the False part.

If the condition is met, the conditional statement inserts the text &quot;Dear NAME, For Washington state residents, we offer special rates to Asia.&quot; as you specified; however, if the condition is not met, only the greeting &quot;Dear NAME,&quot; appears.

Use the following example to suppress the message to Washington state residents when the MERGEFIELD STATE is not equal to WA:

{MERGEFIELDNAME}

{MERGEFIELDADDRESS1}

{MERGEFIELDCITY},{MERGEFIELDSTATE}{MERGEFIELDPOSTALCODE}

{IF{MERGEFIELDSTATE}=&quot;WA&quot;&quot;Dear{MERGEFIELDNAME},

ForWashingtonstateresidents,weofferspecialratestoAsia.&quot;&quot;Dear{MERGEFIELDNAME},&quot;}

Example 2
Microsoft Word suppresses blank lines when the result of a MERGEFIELD is blank. This is especially useful in an address. Word suppresses the blank line when the result of the MERGEFIELD on that line is blank.

NOTE: There must not be any additional text, punctuation, spaces, or fields on the same line that contains the MERGEFIELD.

However, there may be some occasion when you need to use a conditional statement in an address. This example demonstrates how to suppress the second address line, if the result of ADDRESS2 is blank.

If your address list contains some records that have a second line for the address (ADDRESS2) and some records that do not have a second line, a blank line may result in your address, as in the following example:

Microsoft Corporation

One Microsoft Way

Redmond, WA 98052-6399

To correct this problem, use an IF field as a conditional statement that compares whether a MERGEFIELD meets a certain value, as in the following example:

{IF{MERGEFIELD}<>&quot;&quot;&quot;True&quot;&quot;False&quot;}

This conditional IF field states that if the MERGEFIELD is not equal to nothing, do the True part; otherwise, do the False part.

If the condition is met, the conditional statement inserts the results of the field (ADDRESS2) as you specified; however, if the condition is not met, the results of the False part of the statement appear.

Use the following example to suppress the second address line when the result of the ADDRESS2 MERGEFIELD is blank:

{MERGEFIELDNAME}

{MERGEFIELDADDRESS1}

{IF{MERGEFIELDADDRESS2}<>&quot;&quot;&quot;{MERGEFIELDADDRESS2}

{MERGEFIELDCITY}{MERGEFIELDSTATE}{MERGEFIELDPOSTALCODE}&quot; &quot;{MERGEFIELDCITY}{MERGEFIELDSTATE}{MERGEFIELDPOSTALCODE}&quot;}

Non-Printing Characters Used in This Article:

To view these non-printing characters in your Word document, do the following:
 * 1) On the Tools menu, click Options.
 * 2) On the View tab, click to select the Field Codes check box (listed in the Show section) and the All check box (listed in the Nonprinting characters section).
 * 3) Click OK to close the Options dialog box.

