Parsing & Rearranging A Fax Field

H

HM

I would like to parse a FAX_NUMBER field which looks like this:
(800)555-1234

and rearrange the string to look like this:
"555-1212", "800"

I'm trying to pass the FAX_NUMBER field in one step to a module which will
then use the specially formatted data. Any thoughts?
 
A

Albert D. Kallal

You could write a function.

Public Function MyPhoneFormat(v As Variant) As Variant

Dim strArea As String
Dim strNum As String
Dim q As String

q = Chr$(34)

If IsNull(v) Then Exit Function

strArea = Mid(v, 2, 3)
strNum = Mid(v, 6)

MyPhoneFormat = q & strNum & q & "," & q & strArea & q

End Function


Now, you can make a query, and for the new column in the query builder use:

myCoolNum:MyPhoneFormat([PhoneNumber])

The above can thus be used in reports...or you can even export the query to
a text file.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top