Blank line is not suppressed in a conditional mail merge (264787)



The information in this article applies to:

  • Microsoft Word 97 for Windows

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}="WA""ForWashingtonstateresidents, weofferspecialratestoAsia."}

<Body of letter...>

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.

<Body of letter...>

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

Name
Address
City,StatePostalCode

DearName,



<Body of letter...>

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 "Summary" 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}="<value>""True""False"}

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

If the condition is met, the conditional statement inserts the text "Dear NAME, For Washington state residents, we offer special rates to Asia." as you specified; however, if the condition is not met, only the greeting "Dear NAME," 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}="WA""Dear{MERGEFIELDNAME},

ForWashingtonstateresidents,weofferspecialratestoAsia.""Dear{MERGEFIELDNAME},"}

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}<>"""True""False"}

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}<>"""{MERGEFIELDADDRESS2}
{MERGEFIELDCITY}{MERGEFIELDSTATE}{MERGEFIELDPOSTALCODE}" "{MERGEFIELDCITY}{MERGEFIELDSTATE}{MERGEFIELDPOSTALCODE}"}

Non-Printing Characters Used in This Article:

Character

 

Description

 

Press These Keys

 

Space

 

SPACEBAR

 

Paragraph Mark

 

ENTER

{}

 

Field Braces

 

CTRL+F9



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.

REFERENCES

For more information about how to suppress blank lines in a mail merge, click the following article number to view the article in the Microsoft Knowledge Base:

264723 How to suppress blank lines during a mail merge

For more information about a similar problem in which Word may not suppress blank spaces for a conditional statement in a mail merge, click the following article number to view the article in the Microsoft Knowledge Base:

72441 Suppressing blank spaces in a print merge (mail merge)


For more information about a conditional IF field, click Contents and Index on the Help menu, click the Index tab in Microsoft Word Help, type the following text

if field

and then double-click the selected text to go to the "Specify multiple conditions with an IF field" topic. If you are unable to find the information you need, ask the Office Assistant.

Modification Type:MinorLast Reviewed:12/29/2005
Keywords:kbfield kbmerge kbprb KB264787