Can I compare more than two merge field values using =AND or =OR?

R

Rhiannon

I'm working in Word 2007. I have a list of mergefields (anywhere between 3
and 7 depending) that I would like to test the values of - if all of them
come back true, return one block of text, else return another block of text.
It works fine when I try and compare the values of two mergefields:

{IF { = AND ( { COMPARE {Mergefield 1} = "Y"}, {COMPARE {mergefield 2} <> 2
} ) } = 1 "true" "false" }

but as soon as I try and compare the values of three or more mergefields:

{IF { = AND ( { COMPARE {Mergefield 1} = "Y"}, {COMPARE {mergefield 2} <> 2
}, { COMPARE {mergefield 3" = "text" } ) } = 1 "true" "false" }

it breaks. Is there a way to expand beyond two comparisons, using either the
=AND or the =OR formulas? I'd rather not start nesting piles of these if I
can help it. Thanks muchly!!
 
D

Doug Robbins - Word MVP

I would suggest that you do the comparing in the data source, moving the
data to Excel of Access to do so if necessary. Both of those programs are
better at manipulating data than Word.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
R

Rhiannon

Thanks Doug.That may, unfortunately, be where I'm at. I'm hoping there's an
alternative because I'm already close to the max number of columns in the
data source, and I need to compare the mergefields in multiple, unique
combinations, which is why I'm hoping to do it in the word doc itself.

Thanks again!
 
M

macropod

Hi Rhiannon,

You can build a multiple AND test this way:
{IF{={IF{MERGEFIELD 1}= "Y" 1 0}*{IF{MERGEFIELD 2}<> 2 1 0}*{IF{MERGEFIELD 3}= "text" 1 0}}= 1 "True Text" "False Text"}

Similarly, you can build a multiple OR test this way:
{IF{={IF{MERGEFIELD 1}= "Y" 1 0}+{IF{MERGEFIELD 2}<> 2 1 0}+{IF{MERGEFIELD 3}= "text" 1 0}}> 0 "True Text" "False Text"}
 

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