Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Compass Rose
 
Posts: n/a
Default OR in a mergefield?

I would like to use OR in an If...then...else... Word Field.

If {MERGEFIELD Company} = "Company A" OR {MERGEFIELD Company} = "Company B"
OR {MERGEFIELD Company} = "Company C" then......

Is it possible, and if so, what is the correct syntax?

TIA
David

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default OR in a mergefield?

There is no OR in the IF field, but there are other ways to achieve the
same effect, depending on exactly what you need.

{ IF "{ MERGEFIELD Company }" = "Company A" "X" "Y" }
{ IF "{ MERGEFIELD Company }" = "Company B" "X" "Y" }

is one way that may be enough in simple situations.

{ COMPARE "{ MERGEFIELD Company }" = "Company A" } returns 1 if Company is
"Company A", 0 otherwise, so you can use

{ IF { =or({ COMPARE "{ MERGEFIELD Company }" = "Company A" },{ COMPARE
"{ MERGEFIELD Company }" = "Company B" }) } = 1 "X" "Y" }

or just use addition, e.g.

{ IF { ={ COMPARE "{ MERGEFIELD Company }" = "Company A" }+{ COMPARE "{
MERGEFIELD Company }" = "Company B" } } 0 "X" "Y" }

Peter Jamieson
"Compass Rose" wrote in message
...
I would like to use OR in an If...then...else... Word Field.

If {MERGEFIELD Company} = "Company A" OR {MERGEFIELD Company} = "Company
B"
OR {MERGEFIELD Company} = "Company C" then......

Is it possible, and if so, what is the correct syntax?

TIA
David



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor
 
Posts: n/a
Default OR in a mergefield?

There is an alternative method for testing for a value in fields shown at
http://www.gmayor.com/formatting_word_fields.htm

--

Graham Mayor - Word MVP

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


Peter Jamieson wrote:
There is no OR in the IF field, but there are other ways to achieve
the same effect, depending on exactly what you need.

{ IF "{ MERGEFIELD Company }" = "Company A" "X" "Y" }
{ IF "{ MERGEFIELD Company }" = "Company B" "X" "Y" }

is one way that may be enough in simple situations.

{ COMPARE "{ MERGEFIELD Company }" = "Company A" } returns 1 if
Company is "Company A", 0 otherwise, so you can use

{ IF { =or({ COMPARE "{ MERGEFIELD Company }" = "Company A" },{
COMPARE "{ MERGEFIELD Company }" = "Company B" }) } = 1 "X" "Y" }

or just use addition, e.g.

{ IF { ={ COMPARE "{ MERGEFIELD Company }" = "Company A" }+{ COMPARE
"{ MERGEFIELD Company }" = "Company B" } } 0 "X" "Y" }

Peter Jamieson
"Compass Rose" wrote in
message ...
I would like to use OR in an If...then...else... Word Field.

If {MERGEFIELD Company} = "Company A" OR {MERGEFIELD Company} =
"Company B"
OR {MERGEFIELD Company} = "Company C" then......

Is it possible, and if so, what is the correct syntax?

TIA
David



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mail merge with 2 different last names to the same address mail merge 2 different last names Mailmerge 1 April 6th 06 07:34 AM
MERGEFIELD error Garry Jones Page Layout 1 January 25th 06 01:29 AM
mail merge - different last names? Robb Microsoft Word Help 1 January 24th 06 06:14 AM
How do I do a conditional mail merge into a table tomtraff Mailmerge 5 March 29th 05 05:29 PM
Math In Merge Field(s) Kenny G Mailmerge 3 March 7th 05 06:57 PM


All times are GMT +1. The time now is 08:56 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"