Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / November 2007

Tip: Looking for answers? Try searching our database.

If Then Else

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pixie - 28 Nov 2007 21:02 GMT
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}}}}}}}}}}
Doug Robbins - Word MVP - 28 Nov 2007 21:17 GMT
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.

Signature

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

> Hello!
>
[quoted text clipped - 25 lines]
> 9
> 0}}}}}}}}}}
Pixie - 29 Nov 2007 13:32 GMT
That worked brilliantly. Thanks so much.

> Use
>
[quoted text clipped - 44 lines]
> > 9
> > 0}}}}}}}}}}
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.