IF OR Statement FOR WORD

N

Newbie

THis is a mialmege for WinWord

Can Someone help me with this syntax. If it is not Provider1 or
Provider2 it prints OR



{if
{ MERGEFIELD Appt_Provider} = "Provider1"
OR
{ MERGEFIELD Appt_Provider} = "Provider 2"
" Yes" " No"}
 
D

Doug Robbins

{ IF { MERGEFIELD Appt_Provider} = "Provider1" "Yes" { IF { MERGEFIELD
Appt_Provider} = "Provider2" "Yes" "No" } }

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
G

Greg Maxey

No. He is showing you how Mailmerge fields are nested in IF fields to
perform AND/OR logic.
 
P

Peter Jamieson

The IF field doesn't support AND and OR. (Have a look in Word Help for the
syntax of these fields!)

If you prefer to use AND and OR explicilty, you can use the following
approach

Use { COMPARE } to make the comparisons, e.g.

{ COMPARE a = b }

gives 1 if a = b and 0 if a <> b

then use the and and or functions within the { = } field to do the logic:

{ =and(a,b) } is 0 if a is 0 or b is 0, and 1 if a and b are 1

then wrap that inside an IF to give the result you need

{ IF { =and(a,b) } = 1 "result if both a and b are non-zero" "result if
either a or b is 0" }

e.g. to take your example,

{ IF { =or({ COMPARE { MERGEFIELD Appt_Provider } = "Provider1" },
{ COMPARE { MERGEFIELD Appt_Provider } = "Provider 2" }) } = 1 "Yes",
"No" }

(I think!)

You can nest ors and ands within the { = } field but notice that in the case
of multiple ors you can should also be able to use

{ IF { ={ COMPARE { MERGEFIELD Appt_Provider } = "Provider1" }+
{ COMPARE { MERGEFIELD Appt_Provider } = "Provider 2" } } > 0 "Yes", "No" }

Not the way I'd design the "field language" but there you go.
 
N

Newbie

Thanks for your help. Trying looking for it in Word Help but could not
find it. Would appreciate if you could steer me to the help screen

Given the complexity of the statement I think I will use the method
listed in a previous reply

I assume that the Select Case is also not supported in a mail merge.
I tried searching help and all I get is stuff on changing from
sentence case to title case
 
P

Peter Jamieson

Trying looking for it in Word Help but could not
find it. Would appreciate if you could steer me to the help screen


It depends on the version, but if you look at the Help Table of Contents,
the fields are generally covered in an item called "Field Types and
Switches" near the bottom of the contents list.
I assume that the Select Case is also not supported in a mail merge.
I tried searching help and all I get is stuff on changing from
sentence case to title case

Correct.
 

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