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 / November 2003

Tip: Looking for answers? Try searching our database.

AND OR in Merge Fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kit Truong - 27 Nov 2003 20:13 GMT
I've got Merge fields in Word 2000 from an Access Database

I'm trying to add conditionals to my merge fields, does any know the syntax?

For example, using the built in merge fields in word, I can get a statement
like {If FIELD1="BLAH" "BLAH" ""}

But now, I want to add a conditional. Something like {If FIELD1="BLAH" OR
FIELD2="BLAH" "BLAH" ""}

Thanks
Peter Jamieson - 28 Nov 2003 02:58 GMT
1. I know you are just giving examples, but do be careful with the IF field
syntax:
a. Despite what some examples may show, you are generally better off using

{ IF { MERGEFIELD field1 }
or
{ IF { REF field1 }
than
{ IF field1
or if you are testing string values, use
{ IF "{ MERGEFIELD field1 }"
or
{ IF "{ REF field1 }"

b. always have a space either side of the comparison operator:
{ IF "{ MERGEFIELD field1 }" = "BLAH"

2. In answer to the question you actually asked, suppose you want

{If FIELD1="BLAH" OR
FIELD2="BLAH" "BLAH" ""}

you can either use the obvious nested IF:

{ IF "{ MERGEFIELD FIELD1 }" = "BLAH"
"BLAH"
"{ IF "{ MERGEFIELD FIELD2 }" = "BLAH"
"BLAH"
"" }" }

For
{If FIELD1="BLAH" AND
FIELD2="BLAH" "BLAH" ""}
you could use

{ IF "{ MERGEFIELD FIELD1 }" = "BLAH"
"{ IF "{ MERGEFIELD FIELD2 }" = "BLAH"
"BLAH" "" }"
"" }
or you can think in terms of generating 0/1 values using COMPARE fields,
then using {=} fields with "and" and "or" functions to test the results,
nested within an { IF } field.

There are limits to the level of nesting (20 I think)

Alternatively, you may be able to use Access queries that use iif functions
etc. to do the same thing and use the queries as the data source for your
merge.

--
Peter Jamieson - Word MVP

> I've got Merge fields in Word 2000 from an Access Database
>
[quoted text clipped - 7 lines]
>
> 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.