A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

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



 
 
Thread Tools Display Modes
  #1  
Old June 13th, 2009, 08:59 PM posted to microsoft.public.word.mailmerge.fields
Rhiannon
external usenet poster
 
Posts: 5
Default Can I compare more than two merge field values using =AND or =OR?

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!!
  #2  
Old June 13th, 2009, 09:52 PM posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default Can I compare more than two merge field values using =AND or =OR?

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
"Rhiannon" wrote in message
...
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!!


  #3  
Old June 13th, 2009, 10:45 PM posted to microsoft.public.word.mailmerge.fields
Rhiannon
external usenet poster
 
Posts: 5
Default Can I compare more than two merge field values using =AND or =

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!


"Doug Robbins - Word MVP" wrote:

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
"Rhiannon" wrote in message
...
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!!



  #4  
Old June 14th, 2009, 04:32 AM posted to microsoft.public.word.mailmerge.fields
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Can I compare more than two merge field values using =AND or =OR?

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

--
Cheers
macropod
[Microsoft MVP - Word]


"Rhiannon" wrote in message ...
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!!

  #5  
Old July 8th, 2009, 11:39 AM posted to microsoft.public.word.mailmerge.fields
8Leonie8
external usenet poster
 
Posts: 2
Default Can I compare more than two merge field values using =AND or =

Hi there,

I'm trying to use the OR function in my Word 2003 document (dutch version),
but I can't get it to work.

I get the following reaction when merging to a new document: Error! Unknown
operator in precondition

Does anyone have an idea why this doesn't work??


"macropod" wrote:

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

--
Cheers
macropod
[Microsoft MVP - Word]


"Rhiannon" wrote in message ...
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!!


  #6  
Old July 8th, 2009, 12:11 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Can I compare more than two merge field values using =AND or =

Did you enter all the brackets with CTRL+F9?

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Hi there,

I'm trying to use the OR function in my Word 2003 document (dutch
version), but I can't get it to work.

I get the following reaction when merging to a new document: Error!
Unknown operator in precondition

Does anyone have an idea why this doesn't work??


"macropod" wrote:

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

--
Cheers
macropod
[Microsoft MVP - Word]


"Rhiannon" wrote in message
...
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!!



  #7  
Old July 8th, 2009, 01:01 PM posted to microsoft.public.word.mailmerge.fields
8Leonie8
external usenet poster
 
Posts: 2
Default Can I compare more than two merge field values using =AND or =

Yes I did. I even followed the help Peter Jamieson has given in the topic
titled "=AND" He says:

then use right-click and toggle field codes to see the result of that part
of the whole construct to see if you can detect which part is causing the
problem.

If I click toggle field code(I'm not sure if that's the correct English word
for this option, I'm translating from the Dutch version of Word), it seems
every part of the function is working. When I click toggle field code for the
different mergefields first I get:
{ IF { =1+1+1}0 "True text" "False text"}
If I go a step further and click toggle field code for {=1+1+1} I get:
{ IF 30 "True text" "False text"}. So far so good, you'd say, but when I
click toggle field code for the last step I get:
Error! Unknown operator in precondition

Hope I've explained my actions in an understandable way, otherwise let me
know.

gr leonie



"Graham Mayor" wrote:

Did you enter all the brackets with CTRL+F9?

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Hi there,

I'm trying to use the OR function in my Word 2003 document (dutch
version), but I can't get it to work.

I get the following reaction when merging to a new document: Error!
Unknown operator in precondition

Does anyone have an idea why this doesn't work??


"macropod" wrote:

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

--
Cheers
macropod
[Microsoft MVP - Word]


"Rhiannon" wrote in message
...
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!!




  #8  
Old July 8th, 2009, 02:16 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Can I compare more than two merge field values using =AND or =

Put a space either side of
thus
{IF 3 0 "True text" "False text"}

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Yes I did. I even followed the help Peter Jamieson has given in the
topic titled "=AND" He says:

then use right-click and toggle field codes to see the result of that
part of the whole construct to see if you can detect which part is
causing the problem.

If I click toggle field code(I'm not sure if that's the correct
English word for this option, I'm translating from the Dutch version
of Word), it seems every part of the function is working. When I
click toggle field code for the different mergefields first I get:
{ IF { =1+1+1}0 "True text" "False text"}
If I go a step further and click toggle field code for {=1+1+1} I get:
{ IF 30 "True text" "False text"}. So far so good, you'd say, but
when I click toggle field code for the last step I get:
Error! Unknown operator in precondition

Hope I've explained my actions in an understandable way, otherwise
let me know.

gr leonie



"Graham Mayor" wrote:

Did you enter all the brackets with CTRL+F9?

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Hi there,

I'm trying to use the OR function in my Word 2003 document (dutch
version), but I can't get it to work.

I get the following reaction when merging to a new document: Error!
Unknown operator in precondition

Does anyone have an idea why this doesn't work??


"macropod" wrote:

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

--
Cheers
macropod
[Microsoft MVP - Word]


"Rhiannon" wrote in message
...
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!!



  #9  
Old July 9th, 2009, 08:08 AM posted to microsoft.public.word.mailmerge.fields
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Can I compare more than two merge field values using =AND or =

Hi Graham,

Only the space after the operand is required - as shown in my post. Spaces before & after won't do any harm, though.

--
Cheers
macropod
[Microsoft MVP - Word]


"Graham Mayor" wrote in message ...
Put a space either side of
thus
{IF 3 0 "True text" "False text"}

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Yes I did. I even followed the help Peter Jamieson has given in the
topic titled "=AND" He says:

then use right-click and toggle field codes to see the result of that
part of the whole construct to see if you can detect which part is
causing the problem.

If I click toggle field code(I'm not sure if that's the correct
English word for this option, I'm translating from the Dutch version
of Word), it seems every part of the function is working. When I
click toggle field code for the different mergefields first I get:
{ IF { =1+1+1}0 "True text" "False text"}
If I go a step further and click toggle field code for {=1+1+1} I get:
{ IF 30 "True text" "False text"}. So far so good, you'd say, but
when I click toggle field code for the last step I get:
Error! Unknown operator in precondition

Hope I've explained my actions in an understandable way, otherwise
let me know.

gr leonie



"Graham Mayor" wrote:

Did you enter all the brackets with CTRL+F9?

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Hi there,

I'm trying to use the OR function in my Word 2003 document (dutch
version), but I can't get it to work.

I get the following reaction when merging to a new document: Error!
Unknown operator in precondition

Does anyone have an idea why this doesn't work??


"macropod" wrote:

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

--
Cheers
macropod
[Microsoft MVP - Word]


"Rhiannon" wrote in message
...
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!!



  #10  
Old July 9th, 2009, 03:34 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Can I compare more than two merge field values using =AND or =

Agreed - though no space will produce the error.

--

Graham Mayor - Word MVP

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



macropod wrote:
Hi Graham,

Only the space after the operand is required - as shown in my post.
Spaces before & after won't do any harm, though.

"Graham Mayor" wrote in message
...
Put a space either side of
thus
{IF 3 0 "True text" "False text"}

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Yes I did. I even followed the help Peter Jamieson has given in the
topic titled "=AND" He says:

then use right-click and toggle field codes to see the result of
that part of the whole construct to see if you can detect which
part is causing the problem.

If I click toggle field code(I'm not sure if that's the correct
English word for this option, I'm translating from the Dutch version
of Word), it seems every part of the function is working. When I
click toggle field code for the different mergefields first I get:
{ IF { =1+1+1}0 "True text" "False text"}
If I go a step further and click toggle field code for {=1+1+1} I
get: { IF 30 "True text" "False text"}. So far so good, you'd say,
but when I click toggle field code for the last step I get:
Error! Unknown operator in precondition

Hope I've explained my actions in an understandable way, otherwise
let me know.

gr leonie



"Graham Mayor" wrote:

Did you enter all the brackets with CTRL+F9?

--

Graham Mayor - Word MVP

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



8Leonie8 wrote:
Hi there,

I'm trying to use the OR function in my Word 2003 document (dutch
version), but I can't get it to work.

I get the following reaction when merging to a new document:
Error! Unknown operator in precondition

Does anyone have an idea why this doesn't work??


"macropod" wrote:

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

--
Cheers
macropod
[Microsoft MVP - Word]


"Rhiannon" wrote in message
...
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!!



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:02 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.