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

Formatting

Status
Not open for further replies.

teferi2002

Technical User
Sep 24, 2005
81
US
I would like to add in the below code to make sure the value in the database for the phone number is not a garbage like this sam-same. I would like to display No phone on the report if the return value is not a number.
I am using CR-10 and oracle 9i thanks for the help

If isnull({CUSTOMER.CONTACT_PHONE}) or
{CUSTOMER.CONTACT_PHONE}="" or
{CUSTOMER.CONTACT_PHONE}="0" or
{CUSTOMER.CONTACT_PHONE}="000-000-" or
{CUSTOMER.CONTACT_PHONE}="000-000-0000?" then

"** No Phone **"
else
"("&(left({CUSTOMER.CONTACT_PHONE},3) & ")" & mid({CUSTOMER.CONTACT_PHONE},5,3) & "-" & right({CUSTOMER.CONTACT_PHONE},4))

 
It seems to me the above formula should work just fine. What is your question? It appears that your "else" statement requires area_code as well as phone_number. If this is the case you might be able to simplify the formula by testing for null, length of string, and all zeros in "mid(field,5,3)" which is your prefix.
 
StringVar phone := Replace({CUSTOMER.CONTACT_PHONE}, "-", "")
if NumericText(phone) and Length(phone) = 10 then
....

will return true if, after removing any hyphens, the remaining values are numbers and it is 10 digits long.
 
Thank you xplodersuv for the reply ...I work with you code and i am getting an error msg.Can you take a look at it.
S

tringVar phone := Replace({CUSTOMER.CONTACT_PHONE}, "-", "")
if NumericText(phone) and Length(phone) = 10 then
"**Not Available**"

else
"("&(left(phone,3) & ")" & mid(phone,5,3) & "-" & right(phone),4)

 
Looks backwards to me, try (adjusted to Crystal Syntax):

StringVar phone := replace(Replace({CUSTOMER.CONTACT_PHONE}, "-", "")," ","");
if NOT(IsNumber(phone))
or
Len(trim(phone)) <> 10) then
"No Phone"
else
picture(phone,"(xxx) xxx-xxxx")

-k
 
Thanks synapsevampire for the help...one more thing some of the field value surrunded by two barcket and how can i make sure it is only one barcket for the area code?
((XXX))this is how it looks like. I just need only one (XXX) thank you guys for your time and help.
 
Try:

StringVar phone := replace(replace(replace(Replace({CUSTOMER.CONTACT_PHONE}, "-", "")," ",""),")",""),"(","");
if NOT(IsNumber(phone))
or
Len(trim(phone)) <> 10) then
"No Phone"
else
picture(phone,"(xxx) xxx-xxxx")

-k
 
It worked fine after i changed Isnumber to NumericText.of course synapsevampire , your help is very much appreciated.thank you agin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top