Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Arden Arden is offline
external usenet poster
 
Posts: 8
Default If-then-else with "or" command

The goal is I am wanting to use an If-then-else statement where the If is
compared to a group of 3 values and I haven't found how to do this in one
statement. For example, I think it should look like: If code = (1 or 2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.

When I posed this question to an online expert, I was directed to the "=OR"
function with the COMPARE statement. It looks like it should work, but I
can't get Microsoft's example code from Help to work: { IF { = OR ( { COMPARE
{ MERGEFIELD CustomerNumber } = 4 }, { COMPARE { MERGEFIELD CustomerRating }
= 9 } ) } = 1 "Credit not acceptable" "Credit acceptable"}

What advice can you offer? Thanks!

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default If-then-else with "or" command

Use the following construction

{ IF { COMPARE { IF { = { MERGEFIELD CustomerNumber } } = { = 4 } 1 0 } =
{ IF { = { MERGEFIELD CustomerRating } } = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}


--
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
"Arden" wrote in message
...
The goal is I am wanting to use an If-then-else statement where the If is
compared to a group of 3 values and I haven't found how to do this in one
statement. For example, I think it should look like: If code = (1 or 2 or
3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.

When I posed this question to an online expert, I was directed to the
"=OR"
function with the COMPARE statement. It looks like it should work, but I
can't get Microsoft's example code from Help to work: { IF { = OR ( {
COMPARE
{ MERGEFIELD CustomerNumber } = 4 }, { COMPARE { MERGEFIELD
CustomerRating }
= 9 } ) } = 1 "Credit not acceptable" "Credit acceptable"}

What advice can you offer? Thanks!


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Arden Arden is offline
external usenet poster
 
Posts: 8
Default If-then-else with "or" command

Thanks for taking the time to reply. The result I get is closer, but it's not
yet complete:

Cust # 4 Cust Rate 2
{ IF { COMPARE { IF { = 4} = { = 4 } 1 0 } =
{ IF { = 2} = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}

when the CustomerNumber = 4 and the CustomerRate = 2.

A little more help?


"Arden" wrote:

The goal is I am wanting to use an If-then-else statement where the If is
compared to a group of 3 values and I haven't found how to do this in one
statement. For example, I think it should look like: If code = (1 or 2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.

When I posed this question to an online expert, I was directed to the "=OR"
function with the COMPARE statement. It looks like it should work, but I
can't get Microsoft's example code from Help to work: { IF { = OR ( { COMPARE
{ MERGEFIELD CustomerNumber } = 4 }, { COMPARE { MERGEFIELD CustomerRating }
= 9 } ) } = 1 "Credit not acceptable" "Credit acceptable"}

What advice can you offer? Thanks!

  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default If-then-else with "or" command

There's a simpler way of testing for results in one of more fields. See
'Testing for a value in one of several fields' at
http://www.gmayor.com/formatting_word_fields.htm

Based on that model, to test whether a Mergefield Code contains the value of
1, 2 or 3 try the following

{ IF{ =({ IF{ MERGEFIELD Code } = "1" 1 0 } + { IF{ MERGEFIELD Code } = "2"
1 0 } + { IF{ MERGEFIELD Code } = "3" 1 0 }) } = 1 "Credit Acceptable"
"Credit Not Acceptable" }


--

Graham Mayor - Word MVP

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



Arden wrote:
Thanks for taking the time to reply. The result I get is closer, but
it's not yet complete:

Cust # 4 Cust Rate 2
{ IF { COMPARE { IF { = 4} = { = 4 } 1 0 } =
{ IF { = 2} = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}

when the CustomerNumber = 4 and the CustomerRate = 2.

A little more help?


"Arden" wrote:

The goal is I am wanting to use an If-then-else statement where the
If is compared to a group of 3 values and I haven't found how to do
this in one statement. For example, I think it should look like: If
code = (1 or 2 or 3) then "TEXT1" "TEXT2". I don't want to use If
code = 1 "TEXT1" "If code = 2 "TEXT1" ... etc for a nested if with
the same text to maintain multiple times.

When I posed this question to an online expert, I was directed to
the "=OR" function with the COMPARE statement. It looks like it
should work, but I can't get Microsoft's example code from Help to
work: { IF { = OR ( { COMPARE { MERGEFIELD CustomerNumber } = 4 },
{ COMPARE { MERGEFIELD CustomerRating } = 9 } ) } = 1 "Credit not
acceptable" "Credit acceptable"}

What advice can you offer? Thanks!



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default If-then-else with "or" command

The original example should work, which suggests that you may not be
entering it correctly.

Typically, it's easier to insert these nested fields "by hand" using
a. ctrl-F9 to insert each pair of the special "field braces" {} (the
ordinary ones on the keyboard do not work)
b. alt-F9 to toggle between "field code" and "field results" view.
c. select one of the "nested" fields inside the IF and use shift-F9 to
toggle just that field so you can see its result.

The goal is I am wanting to use an If-then-else statement where the

If is
compared to a group of 3 values and I haven't found how to do this

in one
statement. For example, I think it should look like: If code = (1 or

2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If

code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.


{ IF { ={ COMPARE code = 1 }+{ COMPARE code = 2 }+{ COMPARE code = 3 } }
0 "code is one of 1,2, or 3" "code is none of 1,2, or 3" }


precisely what you put for "code" depends on what kind of thing "code"
is - if it's a mergefield, you would either need to use { MERGEFIELD
code } instead of code, i.e.

{ IF { ={ COMPARE { MERGEFIELD code } = 1 }+{ COMPARE { MERGEFIELD code
} = 2 }+{ COMPARE { MERGEFIELD code } = 3 } } 0 "code is one of 1,2,
or 3" "code is none of 1,2, or 3" }

or set a bookmark prior to the comparison and use that instead, e.g.

{ SET code2 { MERGEFIELD code } }{ IF { ={ COMPARE { MERGEFIELD code2 =
1 }+{ COMPARE code2 = 2 }+{ COMPARE code2 = 3 } } 0 "code is one of
1,2, or 3" "code is none of 1,2, or 3" }


Peter Jamieson
http://tips.pjmsn.me.uk

Arden wrote:
Thanks for taking the time to reply. The result I get is closer, but it's not
yet complete:

Cust # 4 Cust Rate 2
{ IF { COMPARE { IF { = 4} = { = 4 } 1 0 } =
{ IF { = 2} = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}

when the CustomerNumber = 4 and the CustomerRate = 2.

A little more help?


"Arden" wrote:

The goal is I am wanting to use an If-then-else statement where the If is
compared to a group of 3 values and I haven't found how to do this in one
statement. For example, I think it should look like: If code = (1 or 2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.

When I posed this question to an online expert, I was directed to the "=OR"
function with the COMPARE statement. It looks like it should work, but I
can't get Microsoft's example code from Help to work: { IF { = OR ( { COMPARE
{ MERGEFIELD CustomerNumber } = 4 }, { COMPARE { MERGEFIELD CustomerRating }
= 9 } ) } = 1 "Credit not acceptable" "Credit acceptable"}

What advice can you offer? Thanks!



  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Arden Arden is offline
external usenet poster
 
Posts: 8
Default If-then-else with "or" command

thanks for your post and your website. I still do not seem to achieve
success, even when using your example, coding:

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0 } ) }
= 1 €œTrue€ €œFalse€ }


When I run the merge, the output shows:

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0 } ) }
= 1 €œTrue€ €œFalse€ }


where the A's, above, represent the data in the table. Why doesn't the
expression fully resolve and just print "True"?

Thanks.

"Peter Jamieson" wrote:

The original example should work, which suggests that you may not be
entering it correctly.

Typically, it's easier to insert these nested fields "by hand" using
a. ctrl-F9 to insert each pair of the special "field braces" {} (the
ordinary ones on the keyboard do not work)
b. alt-F9 to toggle between "field code" and "field results" view.
c. select one of the "nested" fields inside the IF and use shift-F9 to
toggle just that field so you can see its result.

The goal is I am wanting to use an If-then-else statement where the

If is
compared to a group of 3 values and I haven't found how to do this

in one
statement. For example, I think it should look like: If code = (1 or

2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If

code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.


{ IF { ={ COMPARE code = 1 }+{ COMPARE code = 2 }+{ COMPARE code = 3 } }
0 "code is one of 1,2, or 3" "code is none of 1,2, or 3" }


precisely what you put for "code" depends on what kind of thing "code"
is - if it's a mergefield, you would either need to use { MERGEFIELD
code } instead of code, i.e.

{ IF { ={ COMPARE { MERGEFIELD code } = 1 }+{ COMPARE { MERGEFIELD code
} = 2 }+{ COMPARE { MERGEFIELD code } = 3 } } 0 "code is one of 1,2,
or 3" "code is none of 1,2, or 3" }

or set a bookmark prior to the comparison and use that instead, e.g.

{ SET code2 { MERGEFIELD code } }{ IF { ={ COMPARE { MERGEFIELD code2 =
1 }+{ COMPARE code2 = 2 }+{ COMPARE code2 = 3 } } 0 "code is one of
1,2, or 3" "code is none of 1,2, or 3" }


Peter Jamieson
http://tips.pjmsn.me.uk

Arden wrote:
Thanks for taking the time to reply. The result I get is closer, but it's not
yet complete:

Cust # 4 Cust Rate 2
{ IF { COMPARE { IF { = 4} = { = 4 } 1 0 } =
{ IF { = 2} = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}

when the CustomerNumber = 4 and the CustomerRate = 2.

A little more help?


"Arden" wrote:

The goal is I am wanting to use an If-then-else statement where the If is
compared to a group of 3 values and I haven't found how to do this in one
statement. For example, I think it should look like: If code = (1 or 2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.

When I posed this question to an online expert, I was directed to the "=OR"
function with the COMPARE statement. It looks like it should work, but I
can't get Microsoft's example code from Help to work: { IF { = OR ( { COMPARE
{ MERGEFIELD CustomerNumber } = 4 }, { COMPARE { MERGEFIELD CustomerRating }
= 9 } ) } = 1 "Credit not acceptable" "Credit acceptable"}

What advice can you offer? Thanks!


  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Arden Arden is offline
external usenet poster
 
Posts: 8
Default If-then-else with "or" command

Thanks for taking the time to teach me about the Ctrl F9!!!



"Arden" wrote:

thanks for your post and your website. I still do not seem to achieve
success, even when using your example, coding:

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0 } ) }
= 1 €œTrue€ €œFalse€ }


When I run the merge, the output shows:

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0 } ) }
= 1 €œTrue€ €œFalse€ }


where the A's, above, represent the data in the table. Why doesn't the
expression fully resolve and just print "True"?

Thanks.

"Peter Jamieson" wrote:

The original example should work, which suggests that you may not be
entering it correctly.

Typically, it's easier to insert these nested fields "by hand" using
a. ctrl-F9 to insert each pair of the special "field braces" {} (the
ordinary ones on the keyboard do not work)
b. alt-F9 to toggle between "field code" and "field results" view.
c. select one of the "nested" fields inside the IF and use shift-F9 to
toggle just that field so you can see its result.

The goal is I am wanting to use an If-then-else statement where the

If is
compared to a group of 3 values and I haven't found how to do this

in one
statement. For example, I think it should look like: If code = (1 or

2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If

code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.


{ IF { ={ COMPARE code = 1 }+{ COMPARE code = 2 }+{ COMPARE code = 3 } }
0 "code is one of 1,2, or 3" "code is none of 1,2, or 3" }


precisely what you put for "code" depends on what kind of thing "code"
is - if it's a mergefield, you would either need to use { MERGEFIELD
code } instead of code, i.e.

{ IF { ={ COMPARE { MERGEFIELD code } = 1 }+{ COMPARE { MERGEFIELD code
} = 2 }+{ COMPARE { MERGEFIELD code } = 3 } } 0 "code is one of 1,2,
or 3" "code is none of 1,2, or 3" }

or set a bookmark prior to the comparison and use that instead, e.g.

{ SET code2 { MERGEFIELD code } }{ IF { ={ COMPARE { MERGEFIELD code2 =
1 }+{ COMPARE code2 = 2 }+{ COMPARE code2 = 3 } } 0 "code is one of
1,2, or 3" "code is none of 1,2, or 3" }


Peter Jamieson
http://tips.pjmsn.me.uk

Arden wrote:
Thanks for taking the time to reply. The result I get is closer, but it's not
yet complete:

Cust # 4 Cust Rate 2
{ IF { COMPARE { IF { = 4} = { = 4 } 1 0 } =
{ IF { = 2} = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}

when the CustomerNumber = 4 and the CustomerRate = 2.

A little more help?


"Arden" wrote:

The goal is I am wanting to use an If-then-else statement where the If is
compared to a group of 3 values and I haven't found how to do this in one
statement. For example, I think it should look like: If code = (1 or 2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.

When I posed this question to an online expert, I was directed to the "=OR"
function with the COMPARE statement. It looks like it should work, but I
can't get Microsoft's example code from Help to work: { IF { = OR ( { COMPARE
{ MERGEFIELD CustomerNumber } = 4 }, { COMPARE { MERGEFIELD CustomerRating }
= 9 } ) } = 1 "Credit not acceptable" "Credit acceptable"}

What advice can you offer? Thanks!


  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default If-then-else with "or" command

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0
} ) }
= 1 €œTrue€ €œFalse€ }


should be

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0 } )
} 0 €œTrue€ €œFalse€ }

Peter Jamieson

http://tips.pjmsn.me.uk

Arden wrote:
thanks for your post and your website. I still do not seem to achieve
success, even when using your example, coding:

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0 } ) }
= 1 €œTrue€ €œFalse€ }


When I run the merge, the output shows:

{ IF { =( { IF A = €œA€ 1 0 } + { IF A = €œB€ 1 0 } + { IF A = €œC€ 1 0 } ) }
= 1 €œTrue€ €œFalse€ }


where the A's, above, represent the data in the table. Why doesn't the
expression fully resolve and just print "True"?

Thanks.

"Peter Jamieson" wrote:

The original example should work, which suggests that you may not be
entering it correctly.

Typically, it's easier to insert these nested fields "by hand" using
a. ctrl-F9 to insert each pair of the special "field braces" {} (the
ordinary ones on the keyboard do not work)
b. alt-F9 to toggle between "field code" and "field results" view.
c. select one of the "nested" fields inside the IF and use shift-F9 to
toggle just that field so you can see its result.

The goal is I am wanting to use an If-then-else statement where the

If is
compared to a group of 3 values and I haven't found how to do this

in one
statement. For example, I think it should look like: If code = (1 or

2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If

code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.


{ IF { ={ COMPARE code = 1 }+{ COMPARE code = 2 }+{ COMPARE code = 3 } }
0 "code is one of 1,2, or 3" "code is none of 1,2, or 3" }


precisely what you put for "code" depends on what kind of thing "code"
is - if it's a mergefield, you would either need to use { MERGEFIELD
code } instead of code, i.e.

{ IF { ={ COMPARE { MERGEFIELD code } = 1 }+{ COMPARE { MERGEFIELD code
} = 2 }+{ COMPARE { MERGEFIELD code } = 3 } } 0 "code is one of 1,2,
or 3" "code is none of 1,2, or 3" }

or set a bookmark prior to the comparison and use that instead, e.g.

{ SET code2 { MERGEFIELD code } }{ IF { ={ COMPARE { MERGEFIELD code2 =
1 }+{ COMPARE code2 = 2 }+{ COMPARE code2 = 3 } } 0 "code is one of
1,2, or 3" "code is none of 1,2, or 3" }


Peter Jamieson
http://tips.pjmsn.me.uk

Arden wrote:
Thanks for taking the time to reply. The result I get is closer, but it's not
yet complete:

Cust # 4 Cust Rate 2
{ IF { COMPARE { IF { = 4} = { = 4 } 1 0 } =
{ IF { = 2} = { = 9 } 1 0 } = 1 "Credit not
acceptable" "Credit acceptable"}

when the CustomerNumber = 4 and the CustomerRate = 2.

A little more help?


"Arden" wrote:

The goal is I am wanting to use an If-then-else statement where the If is
compared to a group of 3 values and I haven't found how to do this in one
statement. For example, I think it should look like: If code = (1 or 2 or 3)
then "TEXT1" "TEXT2". I don't want to use If code = 1 "TEXT1" "If code = 2
"TEXT1" ... etc for a nested if with the same text to maintain multiple
times.

When I posed this question to an online expert, I was directed to the "=OR"
function with the COMPARE statement. It looks like it should work, but I
can't get Microsoft's example code from Help to work: { IF { = OR ( { COMPARE
{ MERGEFIELD CustomerNumber } = 4 }, { COMPARE { MERGEFIELD CustomerRating }
= 9 } ) } = 1 "Credit not acceptable" "Credit acceptable"}

What advice can you offer? Thanks!

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
Where is the "AutoSum" command in Mircosoft Office Work 2007 Rickh957 Microsoft Word Help 11 June 26th 09 03:42 PM
Missing "Page Setup" command from File menu Mike Microsoft Word Help 2 March 24th 09 06:30 PM
Can you change the order of tabs in "Format Picture" command? atomspam Microsoft Word Help 0 July 25th 07 05:28 AM
How do I "reset" the FIND command under EDIT to use page scrolling Aunt Lorraine Microsoft Word Help 2 April 3rd 07 07:20 PM
In Word and Excel, the command "File/Save as" does not respond Word One New Users 1 April 25th 06 05:03 AM


All times are GMT +1. The time now is 12:15 PM.

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"