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!

Problem with compound expressions 1

Status
Not open for further replies.

ssampier

ISP
Sep 16, 2004
43
0
0
US
I have a phone number containing the area code, a dash after the area code, and a dash after the prefix. I would like to remove both dashes and remove the area code. Both would be replaced with a null character so a phone number 999-123-4567 would be 1234567 instead.

To this, I have two separate expressions that do what I want. However, I am unable to combine into one compound expression. I have used AND and & to combine them. The first returns a -1, the latter returns a long string (the concatenate).

Here is my two separate expressions that I'd like to combine so I have the dashes and area code removed:

Code:
Expr1: Replace([PhoneNumber],"-","")

This removes the hyphen, replaces with null value.

Code:
Expr2: Right([PhoneNumber],7)

This removes the area code by selecting seven characters from the RIGHT of the field.

I'm not exactly sure how to write expressions in SQL, so I merely used the Access query list (I have the most experience with SELECT statements).
 
Code:
Right(Replace([Phonenumber], "-", ""), 7)

_______
I love small animals, especially with a good brown gravy....
 
Pkailas,

That did the trick! The simple solutions are usually the best ones. I really appreciate your help!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top