Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Phone Number Format with Extn. 6

Status
Not open for further replies.

jonbarr

MIS
Jun 20, 2003
66
0
0
NZ
Using CR 8.0

I have a string field of 14 digits to show phone numbers.
I would like to display the result in the following format
(780)123-4567 Extn. 9999

I have used the following formula adapted from answers found in previous threads -
Picture({RM00102.PHONE1},"(XXX) XXX-XXXX-Extn.-XXXX")
but get the following result
(780) 123-4567 E9tn. 999

The "x" in Extn. is being replaced by the first digit of the last group of four digits.

Is there any way to write this formula to display "Extn." without the x being substituted by a digit from the string ?
 
Hi jon,

Yes - You could also use:

"(" & {RM00102.PHONE1}[1 to 3] & ")" & {RM00102.PHONE1}[4 to 6] & "-" & {RM00102.PHONE1}[7 to 10] & "-" &"Extn." &
{RM00102.PHONE1}[11 to 14]

Cheers
paulmarr
 
A bit simpler is:

picture(totext({table.field},0,""),"(xxx) xxx-xxxx -Extn.- xxx")

-k
 
Thanks for your reply, synapse.

I agree your formula is much simpler, but I had already tried that and get the error message
"Too many arguments have been given to this function"
with the cursor flashing just before the 'totext'.

Maybe it's a version 8.0 thing.
Meantime, Paul's less simple formula works fine.
 
Guys,

The reason the original formula doesn't work is because the label for Extention Phone Number contains an "x" - which is the symbol the Picture() function uses as a placeholder for the real data.

What happens when a label contains an 'x' like "Fax:"? You can't use the Picture() function - unless you chnage your label to "Facsimile:" or something without the "x"!

Cheers
paulmarr
 
You could use a formula like the following instead:

replace(picture({table.string},"(xxx) xxx-xxxx ektn xxxx"),"k","x")

-LB
 
Yes, that works fine, lbass.
More than one way to skin a cat, hey ?

Thank you for demonstrating the 'replace' function -
yet again I've learnt something new from your posts .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top