Parsing & Rearranging A Fax Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.....
 
Back
Top