Parsing Part of a Number for a Logic Statement in a Word Field Code

R

Ritland

Is it possible to parse a 7 digit number so that a field code logic
statment is based only on the value of the last 2 digits?

I am quite new to editing field codes for Microsoft Word 2002. I would
like to create a logic statement that would produce a true/false value
based on the last 2 digits of a 7 digit number. For instace, our
company has a filing system which is based on YEAR-CASE#-CASETYPE
where the case type is represented by a numerical value. For instance,
for an operations case (which is coded as "31"), the filing number
would be 09-001-31. I like to create a field code statement that would
see whether the last two digits of the case number were "31" and
output a TRUE value.

Is this possible? Thanks so much.
 
D

Doug Robbins - Word MVP

Where exactly does the filing number appear? Is it the name of the file? or
is it displayed in a field in the document, and if so, what type of field?

As a reference such as 09-001-31 would be a string, using the
Right("stringname", 2) function will return the last two characters (in this
case digits) of the number.

What we need to determine is how to get hold of the 09-001-31

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

macropod

Hi Ritland,

How are you getting the string, and how is it formatted?

If it's just a multi-digit string-
For a mailmerge you could use a field coded as:
{=MOD({MERGEFIELD Data},100) \# 00}
where 'Data' is the field name in the datasource.

For a filename you could use a field coded as:
{=MOD({FILENAME},100) \# 00}

For a formfield you could use a field coded as:
{=MOD({REF Text1},100) \# 00}
where 'Text1' is the formfield's bookmark name.


If it's a string coded as YEAR-CASE#-CASETYPE -
For a mailmerge you could use a field coded as:
{QUOTE
{SET ID {MERGEFIELD Data}}
{SET Right{=({ID}*(-1)-ID)/2}}{IF{Right \# 00}= 31 "True" "False"}}
where 'Data' is the field name in the datasource.

For a filename you could use a field coded as:
{QUOTE
{SET ID {FILENAME}}
{SET Right{=({ID}*(-1)-ID)/2}}{IF{Right \# 00}= 31 "True" "False"}}

For a formfield you could use a field coded as:
{QUOTE
{SET ID {REF Text1}}
{SET Right{=({ID}*(-1)-ID)/2}}{IF{Right \# 00}= 31 "True" "False"}}
where 'Text1' is the formfield's bookmark name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top