using "OR" field?

M

macropod

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
 
M

macropod

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
 
L

Lara Z

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?
 
L

Lara Z

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"}
 
S

smcash

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
 
P

Peter Jamieson

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
 
G

Greg Maxey

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.
 
G

Greg Maxey

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" }
 
G

Greg Maxey

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" }

:)
 
G

Greg Maxey

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.
 
P

Peter Jamieson

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
 
G

Greg

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
 
L

Lara Z

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.
 

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