Controling Text when Fields Are Empty

M

Mike Dalton

I am using my Outlook contacts and Mail Merge to build an MS word
document. My contacts all contain 'Home' data but some also have work
telephone numbers. When printing lists I always want to show the home
tn and only want to show the work tn when it is present. I can do all
of the above. What I am having trouble with is when both tns are
present. I would like to be able to label which is which by shownig a
(W) and (H) after each tn. See examples below.

No Work TN

John Smith
15 John St
Anytown, NY 12345
999-555-1212


With A Work TN

John Smith
15 John St
Anytown, NY 12345
999-555-1212(H)
888-111-2222(W)

Thanks for any and all help.
 
G

Graham Mayor

Use conditional fields eg
{IF {Mergefield WorkPhone} <> "" "{Mergefield HomePhone}(H)
{Mergefield WorkPhone}(W)" "{Mergefield HomePhone}"}

The line break after (H) is inserted from the keyboard. It is not a line
wrap.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

Mike Dalton

OK so far so good. But I have 2 questions.
1 Why does the home TN of the first person on the contact list show
when the View Merged Data is off? Because my document is a list of
names and addresses I set up the merge fields for the first name and
then did a copy and paste with Next Record field for the rest of the
list. As a result this first contact TN is shown throughout the
document. There is no problem after I do the View Merged Data until I
undo the View Merged Data.
2 Some contacts do not have any TN and I have the Suppress Blank Lines
When Data Fields Are Empty option set. Yet a blank line is inserted
for those contacts without a TN.
Once again Thanks.
 
G

Graham Mayor

What is displayed in your merge source document is irrelevant. It is what is
in the merged document (or print run) that matters.

I am not sure why you are using NEXT fields unless this document is a label
merge.For lists, use a Directory/Catalog merge, and enter the fields once!

Conditional fields don't respond to the clear blank lines rules. If some of
your addresses don't have numbers and you want to clear the blank line thus
created, then insert the linefeed as part of the field result and put the
field construction on the same line as the ZIP code.
ie
{Mergefield ZIP}{IF {Mergefield WorkPhone} <> "" "
{Mergefield HomePhone}(H)
{Mergefield WorkPhone}(W)" "
{Mergefield HomePhone}"}

Again the line breaks are deliberate

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

Mike Dalton

Set it up as a Catalog and that worked well. Tried breaking up the If
statement as you suggested but blank lines still printed when there
was no TN. I can live with this as the contact does have a Home TN but
I do not know it yet. When I get it the problem will be hidden.
Thanks again!!
 
G

Graham Mayor

It needs a minor adjustment ;)

{ IF{ MERGEFIELD WorkPhone } <> "" "{ IF{ MERGEFIELD HomePhone } <> "" "{
MERGEFIELD HomePhone } (H) }¶
{ MERGEFIELD WorkPhone } (W)" "¶
{ IF{ MERGEFIELD HomePhone } <> "" "{ MERGEFIELD HomePhone }" "" }" }

As this is likely to break in your news editor, I have used ¶ to represent
the true line breaks.

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

My web site www.gmayor.com

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

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