Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / April 2004

Tip: Looking for answers? Try searching our database.

How do I use IF THEN comparing 2 merge fields?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AFN - 21 Apr 2004 23:09 GMT
I'm doing a mail merge with Word from Office XP.  I have these fields in my
datasource:
FirstName
LastName
AccountName

Sometimes AccountName is the same as FirstName + " " + LastName.   But other
times, the AccountName is a business name that is totally different than a
person's name.

I want to print the AccountName field only if it is different than the
person's [first and last name].  But the If/Then dialog window doesn't give
me the option to compare one datasource field (AccountName) to the
concatenation of two other data fields (FirstName + " " + LastName) and
insert a datasource field (AccountName) if they are not equal to each other,
else insert nothing.    How do I do this?   Thanks.
Peter Jamieson - 21 Apr 2004 23:51 GMT
Insert the field directly using ctrl-F9 for the special braces and using
Alt-F9 to toggle between "field codes" and field results".

Then you can do something lke:

{ MERGEFIELD FIrstName } { MERGEFIELD LastName }
{ IF "{ MERGEFIELD AccountName }" = "{ MERGEFIELD FirstName } { MERGEFIELD
LastName }"
""
"{ MERGEFIELD AccountName }" }

Signature

Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

> I'm doing a mail merge with Word from Office XP.  I have these fields in my
> datasource:
[quoted text clipped - 12 lines]
> insert a datasource field (AccountName) if they are not equal to each other,
> else insert nothing.    How do I do this?   Thanks.
AFN - 22 Apr 2004 00:13 GMT
That works beautifully!  Thanks.  I didn't realize that you were allowed to
put quotes around things.

But how can I suppress the whole line if there is nothing to display (your
empty quotes below)?  I was reading that you have to encapsulate the line
break with Word 2002/XP, but I don't know how to reveal or encapsulate it.

Again, thanks.

> Insert the field directly using ctrl-F9 for the special braces and using
> Alt-F9 to toggle between "field codes" and field results".
[quoted text clipped - 27 lines]
> other,
> > else insert nothing.    How do I do this?   Thanks.
Peter Jamieson - 22 Apr 2004 08:23 GMT
> But how can I suppress the whole line if there is nothing to display (your
> empty quotes below)?

If what you want is

where the FirstName LastName & Accountname differ:

FirstName LastName
Accountname
further text

where the FirstName LastName & Accountname are the same:

FirstName LastName
further text

then try:

{ MERGEFIELD FIrstName } { MERGEFIELD LastName
}
{ IF "{ MERGEFIELD AccountName }" = "{ MERGEFIELD FirstName } { MERGEFIELD
LastName }"
""
"{ MERGEFIELD AccountName }" }Further text

You can put ordinary paragraph marks etc. inside the IF field results simply
by including the return inside the result text, e.g. if you have

a{ IF x = y "b" "b
" }c

then if x = y you should see

abc

and if x <>y you should see
ab
c

Signature

Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

> That works beautifully!  Thanks.  I didn't realize that you were allowed to
> put quotes around things.
[quoted text clipped - 37 lines]
> > other,
> > > else insert nothing.    How do I do this?   Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.