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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting a phone number from a text string 4

Status
Not open for further replies.

userjf

Technical User
Jun 25, 2004
11
US
Have used some general Crystal formulas, and now must learn advanced formulas & SQL---so I hope to use a lot of those great archived threads & tips within this forum!

Crystal 8.5 user with 2 basic questions:

1) I have a text (String [7]) characters that contains a 'telephone' number. How do you insert the "-" in the number? (ie: 4843232 would appear as 484-3232)

2) My ultimate goal would be to concantenate (term?) the phone number from #1 with the area code (String [3]). Can you instruct me on how to do this?



 
Hi,

Try;

{areacode}+" "+left({phonenbr},3)+" - "+right({phonenbr},4)

Nuffsaid.
 
THANKS TO BOTH OF YOU FOR YOUR PROMPT RESPONSES!

Found out I should have corrected my thread to state that I needed to use both fields so that they would appear as standard phone listings in a document: (247) 545-3715. So I modified both of your suggestions:

"("+{areacode}+")" "+left({phonenumbr},3)+"-"+right({phonenumbr},4)

Picture({areacode}+{phonenumbr},"(XXX) XXX-XXXX")


Note to DGILLZ: on the first Picture formula,
Picture({Your7digitfield},"XXX-XXXX})
I received an error message that
'the matching " for this string is missing'.
I was able to replace the } with a " and all worked well. Still want to THANK YOU for your assistance in this matter, I do plan to visit your website soon. :+)
 
You might want to do some error checking as well, often times data entry doesn't have the proper number of didgits so the display might reflect that:

if isnull({areacode}) or
isnull({phonenumbr}) or
len({areacode}) <> 3 or
len({phonenumbr}) <> 7 then
"Error"+Picture({areacode}+{phonenumbr},"(XXX) XXX-XXXX")
else
Picture({areacode}+{phonenumbr},"(XXX) XXX-XXXX")

-k
 
Dgillz,

It's been sooo long I forgot Picture was available in 8.5

Synaps,

We live in a "Perfect World", no need for error checking!!

[bugeyed] [lol][lol]



Nuffsaid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top