If, Then Else Blanks

K

Kerry Purdy

Hi,

I am using Word XP & Excel XP as my data source.

My data source has 5 address fields and a post code field, I also have a DX
address field. I would like the DX address to be shown on my mail merge
letters & envelopes if one is listed, otherwise I would like the 6 mailing
address field details to show.

I have managed this by using IF Then Else in my word document.

{IF {MERGEFIELD DX}=â€â€ “{MERGEFIELD Add1}†“{MERGEFIELD DX}â€}
{IF {MERGEFIELD DX}=â€â€ “{MERGEFIELD Add2}â€}
{IF {MERGEFIELD DX}=â€â€ “{MERGEFIELD Add3}â€}
{IF {MERGEFIELD DX}=â€â€ “{MERGEFIELD Add4}â€}
{IF {MERGEFIELD DX}=â€â€ “{MERGEFIELD Add5}â€}
{IF {MERGEFIELD DX}=â€â€ “{MERGEFIELD Postcode}â€}

This is working fine to a point - only showing the DX if there is data,
showing the mailing address if no DX details are recorded.

The problem I have is that it's printing the blank lines where an address
field has not been filled. If I have no Add3 value I have a blank line in my
envelope and letter. Also, where only a DX address is being printed is
doesn't close the spaces between that and the start of my letter.

I hope this question makes sense. Is there something I can add to my IF
Then Else? Do I need to try another method? Do you have any suggestions
please.

Manys thanks in advance for your time.

Kerry.
 
D

Doug Robbins - Word MVP

You need to use a construction like this:

{IF {MERGEFIELD DX}="" "{MERGEFIELD Add1}¶
{MERGEFIELD Add2}¶
{IF {MERGEFIELD Add3}="" "{MERGEFIELD Add4}" "{MERGEFIELD Add3}¶
{MERGEFIELD Add4}"}¶
{MERGEFIELD Add5}¶
{MERGEFIELD Postcode}" "{MERGEFIELD DX}"}

Where you use Enter or Shift+Enter in place of each ¶ above.

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

Kerry Purdy

Hi Doug

Thanks for the reply, I have used your example exactly - using soft returns
where you have used the special character in the example. This still leaves
blank lines if there are any address fields empty. Is there another
suggestion or a way I can concatenate the 6 address fields with a soft/hard
return as part of the output?

Many thanks

Kerry
 
G

Graham Mayor

Plan B

{ IF{ Mergefield DX } <> "" "{ Mergefield DX }" "{ Mergefield Add1 }{IF {
Mergefield Add2 } <> "" "¶
{ Mergefield Add2 }" }{ IF { Mergefield Add3 } <> "" "¶
{ Mergefield Add3 }" }{ IF { Mergefield Add4 } <> "" "¶
{ Mergefield Add4 }" }{ IF { Mergefield Add5 } <> "" "¶
{ Mergefield Add5 }" }{ IF { Mergefield PostCode } <> "" "¶
{ Mergefield PostCode }" }" }


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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