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>>
 
D

Doug Robbins - Word MVP

You need to use an If...then...Else field construction as follows:

{ IF { MERGEFIELD County } <> "" "{ MERGEFIELD County }¶
{ IF { MERGEFIELD Country <> "" "{ MERGEFIELD Country }¶
{ MERGEFIELD Nextmergefield }" "{ MERGEFIELD Nextmergefield }" }" "{ IF {
MERGEFIELD Country <> "" "{ MERGEFIELD Country }¶
{ MERGEFIELD Nextmergefield }" "{ MERGEFIELD Nextmergefield }" }

You must use Ctrl+F9 to insert each pair of field delimiters { } and where
the pilcrows (¶) appear in the above, press Enter or Shift+Enter

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
E

eggedd2k

You need to use an If...then...Else field construction as follows:

{ IF { MERGEFIELD County } <> "" "{ MERGEFIELD County }
{ IF { MERGEFIELD Country <> "" "{ MERGEFIELD Country }
{ MERGEFIELD Nextmergefield }" "{ MERGEFIELD Nextmergefield }" }" "{ IF {
MERGEFIELD Country <> "" "{ MERGEFIELD Country }
{ MERGEFIELD Nextmergefield }" "{ MERGEFIELD Nextmergefield }" }

You must use Ctrl+F9 to insert each pair of field delimiters { } and where
the pilcrows ( ) appear in the above, press Enter or Shift+Enter

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
thanks v.muc doug. I'll give that a go on Monday morning when I'm back
in the office.

btw. where are the pilcrows supposed to appear?
 
D

Doug Robbins - Word MVP

I do not know why they did not appear in your response, but I have replaced
them with an X
{ IF { MERGEFIELD County } <> "" "{ MERGEFIELD County }X
{ IF { MERGEFIELD Country <> "" "{ MERGEFIELD Country }X
{ MERGEFIELD Nextmergefield }" "{ MERGEFIELD Nextmergefield }" }" "{ IF {
MERGEFIELD Country <> "" "{ MERGEFIELD Country }X
{ MERGEFIELD Nextmergefield }" "{ MERGEFIELD Nextmergefield }" }

You press Enter (or Shift+Enter) ONLY where the X appears. Ignore any other
line breaks that are inserted by the newsgroup software.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
E

eggedd2k

thanks both very much. this will be the first thing i do on monday
morning when i get to the office.

any ideas what the \*MERGEFORMAT switch does?
 
E

eggedd2k

Suzanne

I gave this a go this morning however it still has the blank line
where the county and country go.

My code looks like this:

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

Graham Mayor

What you should do is put the fields on the same line as the CITY field and
press the enter key only where you see the ¶ symbol. Thus effectively the
City, County and Country fields are all on the same line. The conditional
line break and the field are inserted only of there is content in the field.
Note that a single space will be considered content!


{ MERGEFIELD SEND_TO }¶
{ MERGEFIELD CLIENT_NAME }¶
{ MERGEFIELD ADDRESSDETAIL }¶
{ MERGEFIELD CITY }{ IF { MERGEFIELD COUNTY } <> "" "¶
{ MERGEFIELD COUNTY }"}{ IF { MERGEFIELD COUNTRY } <> "" "¶
{ MERGEFIELD COUNTRY }"}¶
{ MERGEFIELD POSTCODE }


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

eggedd2k

All working now - using the code below:

{ MERGEFIELD Send_To }
{ MERGEFIELD Client_Name }
{ MERGEFIELD AddressDetail }
{ MERGEFIELD City }
{IF {MERGFIELD County } <> "" "{ MERGEFIELD County }
}{ IF {MERGEFIELD Country } <> "" "{ MERGEFIELD Country }
{ MERGEFIELD PostCode }
}{ MERGEFIELD Postcode }

Thanks again for your help on this!!
 

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