How do you suppress blank Address lines during a Word merge?

E

eggedd2k

I'm having some problems getting the address part of the data source
to display correctly. I'm merging from an SQL data source/query.

In particular the County and Country parts are showing as blank lines
if the corresponding field is empty. Some
clients in our database do not have anything in the County or Country
fields and therefore I need these fields to
supress if they are blank - and instead display the PostCode line
instead - rather than showing as a blank line.

The fields codes are shown as below.

Can anyone show me how I need to format the County and Country fields
so that they don't display if they are empty BUT ensure that they
don't leave blank lines?

thanks very much

Field Codes:

{MERGEFIELD SEND_TO \*MERGEFORMAT}
{MERGEFIELD CLIENT_NAME \*MERGEFORMAT}
{MERGEFIELD ADDRESSDETAIL \*MERGEFORMAT}
{MERGEFIELD CITY \*MERGEFORMAT}
{MERGEFIELD COUNTY \*MERGEFORMAT}
{MERGEFIELD COUNTRY \*MERGEFORMAT}
{MERGEFIELD POSTCODE \*MERGEFORMAT}




Fields:

<<Send_To>>
<<Client_Name>>
<<AddressDetail>>
<<City>>
<<County>>
<<Country>>
<<PostCode>>
 
S

Suzanne S. Barnhill

Word's ability to suppress blank lines in a mail merge of this type
unfortunately goes out the window if you use line breaks instead of
paragraph breaks, but you can get around it with IF fields.

For COUNTY, for example, you use this field:

{ IF { MERGEFIELD COUNTY } = "" "" "{ MERGEFIELD COUNTY }
" }

Note the line break after the second merge field and before the closing
quote. This makes the line break part of the FalseText. The result will be
that if the COUNTY field is blank (""), then nothing will be inserted; if it
is not blank, the contents will be printed, followed by a line break. So
your whole address block will look like this (MERGEFORMAT switches omitted
to prevent wrapping errors in this text format):

{ MERGEFIELD SEND_TO }
{ MERGEFIELD CLIENT_NAME }
{ MERGEFIELD ADDRESSDETAIL }
{ MERGEFIELD CITY }
{ IF { MERGEFIELD COUNTY } = "" "" "{ MERGEFIELD COUNTY }
" }{ IF { MERGEFIELD COUNTRY } = "" "" "{ MERGEFIELD COUNTRY }
" }{ MERGEFIELD POSTCODE }

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
Joined
Feb 23, 2016
Messages
1
Reaction score
0
I am having this same problem and followed your instructions (as best as I could as I am not the author of the SQL file, just the person formatting the Word template). Here is what I substituted (without successful results).

{ MERGEFIELD BillingName }
{ MERGEFIELD BillingCompany }
{ MERGEFIELD BillingAddr1 }
{ IF { MERGEFIELD BillingAddr2 } = "" "" "{ MERGEFIELD BillingAddr2 }{MERGEFIELD BillingCityStZip }

When I went to copy and paste it, however, the field codes weren't toggled and show this:

«BillingName»
«BillingCompany»
«BillingAddr1»
MERGEFIELD«BillingCityStZip»

Can someone please advise?
 

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