parse phone numbers

kleblanc

AccessDude
Local time
Today, 15:59
Joined
Jan 15, 2004
Messages
12
I am looking for code that will take the phone number entered in a text box and parse out anything that is not a number and return only the numbers with no spaces.

(504) 123-1234

>>to>>

5041231234

Can anyone help?
 
Use an Input Mask

ie..

in the Input Mask property:

(000) 000-0000


This'll do it for you.
 
My problem with using an input mask is that most of my data is exported from a client db and sent to me. I don't have control over their system and I don't have the time to be doing find and replace every time I want to import to my db. If I get the data in my system I can run a loop to parse the phone and fax inside access.

The other problem is we use temp workers to type into my system at tradeshows. Some of these poeple are older and get pissy when they can't type the phone number the way they want. I get this allot. There is no time to properly train someone set in there ways when there are 2000 poeple in line trying to register.
 
Put this in a module and call it where you need it...

Code:
Public Function RemoveNonNumerical(ByVal strText As String) As String
    Dim intCounter As Integer
    For intCounter = 1 To Len(strText)
        If IsNumeric(Mid(strText, intCounter, 1)) Then
            RemoveNonNumerical = RemoveNonNumerical & Mid(strText, intCounter, 1))
        End If
    Next intCounter
End Function
 
Thank You very much!

I did some mod to the function to suit my needs and it worked great.

Thanks again.

Public Sub RemoveNonNumerical()
Dim intCounter As Integer
Dim strText As String
Dim RemoveNonNumerical As String
strText = Me.Phone
For intCounter = 1 To Len(strText)
If IsNumeric(Mid(strText, intCounter, 1)) Then
RemoveNonNumerical = RemoveNonNumerical & Mid(strText, intCounter, 1)
End If
Next intCounter
Me.Phone = RemoveNonNumerical
End Sub
 

Users who are viewing this thread

Back
Top Bottom