[AccessD] Returning only numbers from a phone number field

rusty.hammond at cpiqpc.com rusty.hammond at cpiqpc.com
Fri Sep 7 08:34:25 CDT 2007


Thanks, I what I ended up doing.

-----Original Message-----
From: Gmail [mailto:max.wanadoo at gmail.com]
Sent: Thursday, September 06, 2007 1:55 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Returning only numbers from a phone number field


Hi Rusty,
This should do the trick for you:

Function teststripNonNumerics()
  MsgBox stripNonNumerics("1.2.3.4/5/6/akjfjakfd-789kjjkaf880-087222/.88")
End Function

Function stripNonNumerics(str As String) As String
  Dim lngLoop As Long, strTemp As String
  For lngLoop = 1 To Len(str)
    If IsNumeric(Mid(str, lngLoop, 1)) Then
      strTemp = strTemp & Mid(str, lngLoop, 1)
    End If
  Next lngLoop
  stripNonNumerics = strTemp
End Function

Regards
Max 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
rusty.hammond at cpiqpc.com
Sent: Thursday, September 06, 2007 6:09 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] Returning only numbers from a phone number field

Is there a built in function that would return only the numbers from a text
field?  I have a table that allows the users to enter a phone number however
they like, ie with or without parentheses or dashes or dots or any
combination of them.

I would like to extract only the numbers (0-9) from this field.  Is there
anything built in to Access 2003 to do this or do I just need to create my
own little function to do it?

TIA, 

Rusty Hammond


**********************************************************************
WARNING: All e-mail sent to and from this address will be received, scanned
or otherwise recorded by the CPI Qualified Plan Consultants, Inc.
corporate e-mail system and is subject to archival, monitoring or review by,
and/or disclosure to, someone other than the recipient.
**********************************************************************
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

**********************************************************************
WARNING: All e-mail sent to and from this address will be received,
scanned or otherwise recorded by the CPI Qualified Plan Consultants, Inc.
corporate e-mail system and is subject to archival, monitoring or review 
by, and/or disclosure to, someone other than the recipient.
**********************************************************************



More information about the AccessD mailing list