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!

Removing Spaces INSIDE a string Access Query

Status
Not open for further replies.

tfhwargt3

Programmer
Sep 19, 2006
61
US
I am trying to remove all parentheses, hyphens, and spaces from a field in Access using the query window and writing regular SQL code. The field is a string field that represents phone numbers. I want to end up with no spaces or non-numerical characters in the string. For example, fields with:

(123) 345-6789
123-345-6789
123 345 6789
(123) 3456789

Would all end up being 123456789 after my query runs.

Right now I have replaced all parentheses and hyphens with spaces using this method:

Replace(Replace(Replace(Addresses.Phone, "(", " "), ")", " "), "-", " ")

All I need to do now is put the string back together. I can accomplish this using the Trim and Mid methods, but if there is a better way please let me know.

Thanks
 
Why replace with spaces? Why not an empty string ("")?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top