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

Tip: Looking for answers? Try searching our database.

AND and OR in the same IF THEN statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan Crow - 27 Sep 2003 22:20 GMT
I am trying to combine AND and OR statements in an if then
statement.

I am trying to test for
if Value_1 is true and (Value_2 is true then put one
thing, or if Value_2 is true put a second thing, or if
Value_3 is true put a third thing).

The code I wrote is:
{IF { MERGEFIELD Code1 } = "A" "{IF { MERGEFIELD Code2 }
= "2a" "A2a" "{ IF {MERGEFIELD Code2 } = "2b" "A2b" "{If
{MERGEFIELD Code2 } = "2c" "A2c" "" }" }" }" "" }

The only result I get is if the value in Code1 = A and the
value in Code2 = 2c, but the result I get is A2a. Any
ideas what I am doing wrong?

Thanks,
Jonathan
Cindy Meister  -WordMVP- - 28 Sep 2003 10:36 GMT
Hi Jonathan,

I don't see anything that should be causing what you
describe, but...
1) Are you certain you used Ctrl+F9 for EACH set of field
brackets { }?
2) If you put "quotes" around the Mergefields to the left of
the =, does that make any difference?
3) Copy each IF field, from the innermost level to the
outermost, one at a time, outside the nested field set and
test if it returns the correct value. Then you can narrow
down where the problem is occurring.

> I am trying to test for
> if Value_1 is true and (Value_2 is true then put one
[quoted text clipped - 9 lines]
> value in Code2 = 2c, but the result I get is A2a. Any
> ideas what I am doing wrong?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan
24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)
Jonathan Crow - 29 Sep 2003 17:59 GMT
Cindy,

I discovered that Word saw the value 2a as a number. So,
2a was equal to 2b was equal to 2c. So, I just took the 2
out of the excel spreadsheet and it worked fine.

Argh word and numbers.

Thanks,
Jonathan

>-----Original Message-----
>Hi Jonathan,
[quoted text clipped - 34 lines]
>
>.
Cindy Meister  -WordMVP- - 30 Sep 2003 13:13 GMT
Hi Jonathan,

In this case, put *both sides* of the comparison equation in
quotes: "2" = "2a" is NOT equal.

With Word IF fields, you need to you quotes very
conscientiously. Where there's an uncertainty whether
numbers or strings are being compared, be sure to use quotes
to enforce string comparisons, and not use quotes if you
want to do something numerical. It won't enforce everything,
but it will help :-)

> I discovered that Word saw the value 2a as a number. So,
> 2a was equal to 2b was equal to 2c. So, I just took the 2
> out of the excel spreadsheet and it worked fine.
>  
> Argh word and numbers.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan
24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
 
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.