find merge field length

R

Raul Bloodworth

Trying to do an if...then...else inside a telephone number merge field (or
vice versa).

Simply, if the merged phone number is greater than eight characters in
length I'd like the area code included for MY phone..

{ IF (LEN{ MERGEFIELD PHONE }>8) "212-" ""} 555-1234}

variants of the above don't work. Any ideas? TIA
 
P

Peter Jamieson

You probably won't be able to do this in Word unless the phone number only
contains digits, but you might be able to use some SQL to derive the
necessary info. from the data source. But which version of Word, and what
(format) is the data source?
 
R

Raul Bloodworth

Word XP, Access XP (formatted as text, no mask)

Peter Jamieson said:
You probably won't be able to do this in Word unless the phone number only
contains digits, but you might be able to use some SQL to derive the
necessary info. from the data source. But which version of Word, and what
(format) is the data source?
 
P

Peter Jamieson

Try creating a query in Access based on the table or query you are currently
using, and add a derived column that does the whole thing, e.g.

iif(len(phonenumberfield) > 8, '212-555-1234', '555-1234') AS 'myphone'
 
P

Peter Jamieson

Sorry, you need backwards quotes for the fiel name I think:

iif(len(phonenumberfield) > 8, '212-555-1234', '555-1234') AS `myphone`
 
R

Raul Bloodworth

myphone: IIf(Len([PHONE])>8,"212-555-1234","555-1234") worked. Thanks for
the tip!
 
Top