View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default If-then-else with "or" command

There's a simpler way of testing for results in one of more fields. See
'Testing for a value in one of several fields' at
http://www.gmayor.com/formatting_word_fields.htm

Based on that model, to test whether a Mergefield Code contains the value of
1, 2 or 3 try the following

{ IF{ =({ IF{ MERGEFIELD Code } = "1" 1 0 } + { IF{ MERGEFIELD Code } = "2"
1 0 } + { IF{ MERGEFIELD Code } = "3" 1 0 }) } = 1 "Credit Acceptable"
"Credit Not Acceptable" }


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Arden wrote:
Thanks for taking the time to reply. The result I get is closer, but
it's not yet complete:

Cust # 4 Cust Rate 2
{ IF { COMPARE { IF { = 4} = { = 4 } 1 0 } =
{ IF { = 2} = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}

when the CustomerNumber = 4 and the CustomerRate = 2.

A little more help?


"Arden" wrote:

The goal is I am wanting to use an If-then-else statement where the
If is compared to a group of 3 values and I haven't found how to do
this in one statement. For example, I think it should look like: If
code = (1 or 2 or 3) then "TEXT1" "TEXT2". I don't want to use If
code = 1 "TEXT1" "If code = 2 "TEXT1" ... etc for a nested if with
the same text to maintain multiple times.

When I posed this question to an online expert, I was directed to
the "=OR" function with the COMPARE statement. It looks like it
should work, but I can't get Microsoft's example code from Help to
work: { IF { = OR ( { COMPARE { MERGEFIELD CustomerNumber } = 4 },
{ COMPARE { MERGEFIELD CustomerRating } = 9 } ) } = 1 "Credit not
acceptable" "Credit acceptable"}

What advice can you offer? Thanks!