#1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Pixie Pixie is offline
external usenet poster
 
Posts: 16
Default If Then Else

Hello!

macropod wrote me a great statement for displaying the last 4 digits of a
16-digit account number - see below:

It works great but only if there is an account number in the field. It turns
out that sometimes there isn't an account number in the field and I get a
syntax error. I want to use an If Then Else statement to use the code if
there is an account number but leave the field blank if there isn't an
account number. I'm not sure how to do it. The Help is written to display
"text" or not and I'm not sure how to deal with quotes and brackets.

Thanks as always for your help!

(QUOTE{SET Data {MERGEFIELD myfield}}{=MOD({=INT({REF Data}/100)-1},100)+1 \
#00}}
{IF{REF Data }= "*1?" 1 {IF{REF Data }= "*2?" 2 {IF{REF Data }= "*3?" 3
{IF{REF Data }= "*4?" 4 {IF{REF Data }= "*5?" 5 {IF{REF
Data }= "*6?" 6 {IF{REF Data }= "*7?" 7 {IF{REF Data }= "*8?" 8 {IF{REF Data
}= "*9?" 9 0}}}}}}}}}
{IF{REF Data }= "*1" 1 {IF{REF Data }= "*2" 2 {IF{REF Data }= "*3" 3 {IF{REF
Data }= "*4" 4 {IF{REF Data }= "*5" 5 {IF{REF Data }=
"*6" 6 {IF{REF Data }= "*7" 7 {IF{REF Data }= "*8" 8 {IF{REF Data }= "*9" 9
0}}}}}}}}}}

  #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

Use

{ IF { MERGEFIELD myfield } "" "{QUOTE{SET Data {MERGEFIELD
myfield}}{=MOD({=INT({REF Data}/100)-1},100)+1 \
#00}}
{IF{REF Data }= "*1?" 1 {IF{REF Data }= "*2?" 2 {IF{REF Data }= "*3?" 3
{IF{REF Data }= "*4?" 4 {IF{REF Data }= "*5?" 5 {IF{REF
Data }= "*6?" 6 {IF{REF Data }= "*7?" 7 {IF{REF Data }= "*8?" 8 {IF{REF Data
}= "*9?" 9 0}}}}}}}}}
{IF{REF Data }= "*1" 1 {IF{REF Data }= "*2" 2 {IF{REF Data }= "*3" 3 {IF{REF
Data }= "*4" 4 {IF{REF Data }= "*5" 5 {IF{REF Data }=
"*6" 6 {IF{REF Data }= "*7" 7 {IF{REF Data }= "*8" 8 {IF{REF Data }= "*9" 9
0}}}}}}}}}} "" }

I have assumed that you have correctly quoted the construction that Macropod
gave you, though I have replaced "(" before the QUOTE with the required "{".

All of the field delimiters { } must be entered by using Ctrl+F9.


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

"Pixie" wrote in message
...
Hello!

macropod wrote me a great statement for displaying the last 4 digits of a
16-digit account number - see below:

It works great but only if there is an account number in the field. It
turns
out that sometimes there isn't an account number in the field and I get a
syntax error. I want to use an If Then Else statement to use the code if
there is an account number but leave the field blank if there isn't an
account number. I'm not sure how to do it. The Help is written to display
"text" or not and I'm not sure how to deal with quotes and brackets.

Thanks as always for your help!

(QUOTE{SET Data {MERGEFIELD myfield}}{=MOD({=INT({REF Data}/100)-1},100)+1
\
#00}}
{IF{REF Data }= "*1?" 1 {IF{REF Data }= "*2?" 2 {IF{REF Data }= "*3?" 3
{IF{REF Data }= "*4?" 4 {IF{REF Data }= "*5?" 5 {IF{REF
Data }= "*6?" 6 {IF{REF Data }= "*7?" 7 {IF{REF Data }= "*8?" 8 {IF{REF
Data
}= "*9?" 9 0}}}}}}}}}
{IF{REF Data }= "*1" 1 {IF{REF Data }= "*2" 2 {IF{REF Data }= "*3" 3
{IF{REF
Data }= "*4" 4 {IF{REF Data }= "*5" 5 {IF{REF Data }=
"*6" 6 {IF{REF Data }= "*7" 7 {IF{REF Data }= "*8" 8 {IF{REF Data }= "*9"
9
0}}}}}}}}}}



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Pixie Pixie is offline
external usenet poster
 
Posts: 16
Default If Then Else

That worked brilliantly. Thanks so much.

"Doug Robbins - Word MVP" wrote:

Use

{ IF { MERGEFIELD myfield } "" "{QUOTE{SET Data {MERGEFIELD
myfield}}{=MOD({=INT({REF Data}/100)-1},100)+1 \
#00}}
{IF{REF Data }= "*1?" 1 {IF{REF Data }= "*2?" 2 {IF{REF Data }= "*3?" 3
{IF{REF Data }= "*4?" 4 {IF{REF Data }= "*5?" 5 {IF{REF
Data }= "*6?" 6 {IF{REF Data }= "*7?" 7 {IF{REF Data }= "*8?" 8 {IF{REF Data
}= "*9?" 9 0}}}}}}}}}
{IF{REF Data }= "*1" 1 {IF{REF Data }= "*2" 2 {IF{REF Data }= "*3" 3 {IF{REF
Data }= "*4" 4 {IF{REF Data }= "*5" 5 {IF{REF Data }=
"*6" 6 {IF{REF Data }= "*7" 7 {IF{REF Data }= "*8" 8 {IF{REF Data }= "*9" 9
0}}}}}}}}}} "" }

I have assumed that you have correctly quoted the construction that Macropod
gave you, though I have replaced "(" before the QUOTE with the required "{".

All of the field delimiters { } must be entered by using Ctrl+F9.


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

"Pixie" wrote in message
...
Hello!

macropod wrote me a great statement for displaying the last 4 digits of a
16-digit account number - see below:

It works great but only if there is an account number in the field. It
turns
out that sometimes there isn't an account number in the field and I get a
syntax error. I want to use an If Then Else statement to use the code if
there is an account number but leave the field blank if there isn't an
account number. I'm not sure how to do it. The Help is written to display
"text" or not and I'm not sure how to deal with quotes and brackets.

Thanks as always for your help!

(QUOTE{SET Data {MERGEFIELD myfield}}{=MOD({=INT({REF Data}/100)-1},100)+1
\
#00}}
{IF{REF Data }= "*1?" 1 {IF{REF Data }= "*2?" 2 {IF{REF Data }= "*3?" 3
{IF{REF Data }= "*4?" 4 {IF{REF Data }= "*5?" 5 {IF{REF
Data }= "*6?" 6 {IF{REF Data }= "*7?" 7 {IF{REF Data }= "*8?" 8 {IF{REF
Data
}= "*9?" 9 0}}}}}}}}}
{IF{REF Data }= "*1" 1 {IF{REF Data }= "*2" 2 {IF{REF Data }= "*3" 3
{IF{REF
Data }= "*4" 4 {IF{REF Data }= "*5" 5 {IF{REF Data }=
"*6" 6 {IF{REF Data }= "*7" 7 {IF{REF Data }= "*8" 8 {IF{REF Data }= "*9"
9
0}}}}}}}}}}




Reply
Thread Tools
Display Modes

Posting Rules

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

Forum Jump


All times are GMT +1. The time now is 11:37 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"