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 / March 2005

Tip: Looking for answers? Try searching our database.

using "OR" field?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lara Z - 28 Mar 2005 20:14 GMT
I am trying to code a merge document that will insert an additional two-page
document if the 'COUNTY' field is one of eight counties. The additional
document is the same for all eight counties. In WordPerfect this could be
done simply with the SWITCH/ENDSWITCH construct. I know there is no
equivalent in Word, but is there any easier way to do this than doing eight
back-to-back IF statements with the same (redundant) two pages of text
inserted in each "then" part of the IF statement? Is there an OR operator in
Word that might help accomplish this?
macropod - 28 Mar 2005 12:27 GMT
Hi Lara,

Part of the limitation of Word's OR test is that it only supports two
conditions, as others have pointed out. This applies to AND tests also.

There is another way, though. Instead of using OR, you could use a numeric
test. For example:
{IF{={IF{MAILMERGE County}= "County1" 1 0}+{IF{MAILMERGE County}= "County2"
1 0}+{IF{MAILMERGE County}= "County3" 1 0}+{IF{MAILMERGE County}= "County4"
1 0}+{IF{MAILMERGE County}= "County5" 1 0}+{IF{MAILMERGE County}= "County6"
1 0}+{IF{MAILMERGE County}= "County7" 1 0}+{IF{MAILMERGE County}= "County8"
1 0}}> 0 "True Statement" "False Statement"}

In this case, adding the result of each IF test works the same as a series
of OR tests. Granted, you'll have nine IF tests, but you only need one true
(and perhaps one false) output statement.

Cheers

> I am trying to code a merge document that will insert an additional two-page
> document if the 'COUNTY' field is one of eight counties. The additional
[quoted text clipped - 4 lines]
> inserted in each "then" part of the IF statement? Is there an OR operator in
> Word that might help accomplish this?
smcash - 28 Mar 2005 20:37 GMT
I'm new to this stuff, but as far as I can tell the operator is simply:

Or

-smcash

> I am trying to code a merge document that will insert an additional two-page
> document if the 'COUNTY' field is one of eight counties. The additional
[quoted text clipped - 4 lines]
> inserted in each "then" part of the IF statement? Is there an OR operator in
> Word that might help accomplish this?
Lara Z - 28 Mar 2005 21:01 GMT
Yes, obviously, but if this is a valid operator what is the syntax for using
it - either in general or with my example, as everything I have tried has
not worked...?? I tried the following and it does not work, i.e., does not
return "Test Positive" or "Test Negative" .

{ IF { = OR ({MERGEFIELD "County"}="Hillsborough", {MERGEFIELD
"County"}="Pinellas")} =1 "Test Positive" "Test Negative"}

> I'm new to this stuff, but as far as I can tell the operator is simply:
>
[quoted text clipped - 13 lines]
>> in
>> Word that might help accomplish this?
smcash - 28 Mar 2005 23:03 GMT
Ok, I noticed a few things. First you need to use a COMPARE, and you've got
some quotes out of place. Here is what I did:

{IF { = OF ( { COMPARE "{ MERGEFIELD County }" = "Hillsborough" }, { COMPARE
"{ MERGEFIELD County }" = "Pinellas" } ) } = 1 "Test Positive" "Test
Negative" }

Also, you can't just type the curly braces, but must insert them with
Ctrl+F9. But you probably knew that already.

-smcash

> Yes, obviously, but if this is a valid operator what is the syntax for using
> it - either in general or with my example, as everything I have tried has
[quoted text clipped - 3 lines]
> { IF { = OR ({MERGEFIELD "County"}="Hillsborough", {MERGEFIELD
> "County"}="Pinellas")} =1 "Test Positive" "Test Negative"}
smcash - 28 Mar 2005 23:07 GMT
Oops, I mistyped OR. Where I wrote OF, it is obviously supposed to be OR.
Greg Maxey - 28 Mar 2005 23:54 GMT
smcash,

The problem with that approach is that it breaks down with the 3rd county

{ IF { = OR ({ Compare  "{ County }" = "Hillsborough" }, { Compare  "{
County }" = "Pinellas" }, { Compare  "{ County }" = "Lake" })} = 1 "Test
Sat""Test Fail" } will generate "Test Fail"

The OR only handles two conditions and you have to keep nesting them which I
find very even more confusing to keeping track of the structure than using
the nested IF field:

{ IF { = OR ({ Compare  "{ County }" = "Pinellas" }, OR ({ Compare  "{
County }" = "Hillsborough" }, OR ({ Compare  "{ County }" = "Lake" }, OR
({ Compare  "{ County }" = "Orange" }, OR ({ Compare  "{ County }" =
"Brevard" }, OR ({ Compare  "{ County }" = "Indian River" }, { Compare  "{
County }" = "Volusia" }))))))} = 1 "Test Sat""Test Fail" }

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Oops, I mistyped OR. Where I wrote OF, it is obviously supposed to be
> OR.
Peter Jamieson - 28 Mar 2005 23:15 GMT
try

{ IF { =or({ COMPARE "{ MERGEFIELD "County" }" = "Hillsborough" },
{ COMPARE "{ MERGEFIELD "County" }" = "Pinellas" }) } = 1
"Test positive" "Test Negative" }

if you ave a thrid comparison, you will need a second OR, e.g.

{ IF { =or(or({ COMPARE "{ MERGEFIELD "County" }" = "Hillsborough" },
{ COMPARE "{ MERGEFIELD "County" }" = "Pinellas" }) ,
{ COMPARE "{ MERGEFIELD "County" }" = "County3" }) } = 1
"Test positive" "Test Negative" }

Unwieldy, isn't it?

Just a suggestion, but if you are inserting form a separate file you might
be better off using the result of the { =} field as part of the file name,
e.g. if you have

Counties0.doc

and

Counties1.doc

you might use

{ INCLUDETEXT "c:\\mydocs\\Counties{{ =or(or({ COMPARE "{ MERGEFIELD
"County" }" = "Hillsborough" },
{ COMPARE "{ MERGEFIELD "County" }" = "Pinellas" }) ,
{ COMPARE "{ MERGEFIELD "County" }" = "County3" }) }.doc"

or you can use 2 bookmark names within a single file to achive something
similar.

Peter Jamieosn
> Yes, obviously, but if this is a valid operator what is the syntax for
> using it - either in general or with my example, as everything I have
[quoted text clipped - 22 lines]
>>> operator in
>>> Word that might help accomplish this?
Greg Maxey - 29 Mar 2005 00:17 GMT
Yes,  this unwieldy:

{ IF { = OR(OR(OR(OR(OR(OR({ Compare  "{ County }" = "Pinellas" }, { Compare
"{ County }" = "Hillsborough" }), { Compare  "{ County }" = "Lake" }), {
Compare  "{ County }" = "Orange" }), { Compare  "{ County }" = "Brevard" }),
{ Compare  "{ County }" = "Indian River" }), { Compare  "{ County }" =
"Volusia" })} = 1 "Test Sat""Test Fail" }

:-)

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> try
>
[quoted text clipped - 57 lines]
>>>> OR operator in
>>>> Word that might help accomplish this?
Greg Maxey - 28 Mar 2005 23:17 GMT
Lara,

These are ugly at best :-)

You could use something like:

{ IF { IF { County }="Pinellas""Set"{ IF { County }=" Hillsborough""Set"{ IF
{ County }="Lake""Set"{ IF { County }="Orange""Set"{ IF {
County }="Brevard""Set"{ IF { County }="Indian River""Set"{ IF {
County }="Volusia""Set"{ IF {
County }="Osceola""Set" } } } } } } } }="Set"{ IncludeText "C:\\Your
Folder\\Your File Name.doc"}"Test Failed/Leave Blank"}

"Set" is just an arbitary word I picked.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Yes, obviously, but if this is a valid operator what is the syntax
> for using it - either in general or with my example, as everything I
[quoted text clipped - 20 lines]
>>> OR operator in
>>> Word that might help accomplish this?
Greg Maxey - 29 Mar 2005 04:32 GMT
Lara,

I found some material that I had squirreled away on Word math fields.  A
bright fellow that goes by Macropod shows us a relatively simple process:

{ If { =({ IF { County } = "Hillsborough""1""0" }+{ IF { County } =
"Pineallas""1" "0"}+{ IF { County } = "Lake""1""0" }+{ IF { County } =
"Orange""1""0" }+{ IF { County } = "Brevard""1""0" }+{ IF { County } =
"Indian River""1""0" }+{ IF { County } = "Volusia""1""0" }+{ IF { County } =
"Oceola""1""0" }) } > 0 "Test Sat""Test Unsat }

Basically you just set up 8 condition equal 0 or 1 and add then up.  One and
only one can be 1 and if any one is 1 then the condition {=(1)} > 0 is met
and the true result displayed. As mentioned earlier, you should replace
"Test Sat" with an IncludeText field or AutoText field.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I am trying to code a merge document that will insert an additional
> two-page document if the 'COUNTY' field is one of eight counties. The
[quoted text clipped - 5 lines]
> part of the IF statement? Is there an OR operator in Word that might
> help accomplish this?
Peter Jamieson - 29 Mar 2005 12:57 GMT
You can probably simplify that using COMPARE via e.g.

{ IF { =({ COMPARE { County } = "Hillsborough" }+{ COMPARE { County } =
"Pineallas" }+{ COMPARE { County } = "Lake" }+{ COMPARE { County } =
"Orange""1""0" }+{ COMPARE { County } = "Brevard" }+{ COMPARE { County } =
"Indian River" }+{ COMPARE { County } = "Volusia" }+{ COMPARE { County } =
"Oceola" }) } > 0 "Test Sat" "Test Unsat" }

Peter Jamieson

> Lara,
>
[quoted text clipped - 21 lines]
>> part of the IF statement? Is there an OR operator in Word that might
>> help accomplish this?
macropod - 28 Mar 2005 14:02 GMT
Hi Peter & Greg,

In either case, you're going to need to set the 'County' value via the
mailmerge. Unless you're planning to do this via a SET field that I haven't
seen explained (eg {SET County {MAILMERGE CountyName}}), you'd both need to
use {MAILMERGE County} instead of {County}.

Cheers

> You can probably simplify that using COMPARE via e.g.
>
[quoted text clipped - 31 lines]
> >> part of the IF statement? Is there an OR operator in Word that might
> >> help accomplish this?
Peter Jamieson - 29 Mar 2005 14:38 GMT
Indeed:-)

I certainly hope Lara Z has some ideas to go on now!

Peter J.
> Hi Peter & Greg,
>
[quoted text clipped - 49 lines]
>> >> part of the IF statement? Is there an OR operator in Word that might
>> >> help accomplish this?
Lara Z - 30 Mar 2005 18:32 GMT
Oh my! I stepped away for a couple of days and came back to lots of great
responses. I am trying macropod's and Maxey's use of a numerical test,
coupled with an INCLUDETEXT command when it returns >1. Works great. Thanks
for all the teriffic dialog/feedback.

> Indeed:-)
>
[quoted text clipped - 55 lines]
>>> >> part of the IF statement? Is there an OR operator in Word that might
>>> >> help accomplish this?
Greg - 29 Mar 2005 20:48 GMT
Macropod,

Yes I knewn that,  I should have mentioned it to the OP.  Since I don't
have a merge field handy I often just substitute a REF field.

I looked for half an hour last night for the file I have on  your math
fields.  I knew there was a relatively easy way to do this.  Thanks
macropod - 29 Mar 2005 08:57 GMT
Hi Greg,

It's currently starred on the Woody's Lounge (www.wopr.com). The full path
is:
www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442
(url all one line)

Cheers

> Macropod,
>
[quoted text clipped - 3 lines]
> I looked for half an hour last night for the file I have on  your math
> fields.  I knew there was a relatively easy way to 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.