Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / December 2005

Tip: Looking for answers? Try searching our database.

remove alpha & special characters from field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jennifer - 06 Dec 2005 18:21 GMT
Hi -

I have an alpha numeric field with entries of varying length and would like
to just keep the numbers

C/O NICK W MANFIELD9653 W BLACKJACK RIDGE

would become 9653

Any help would be appreciated!  Thanks
John Spencer - 06 Dec 2005 19:11 GMT
Here is a bit of code I wrote a while back.  Copy it and put it into a
module.  Then you can call it when you want.

'----------------- Code starts ------------------------
Public Function fStripToNumbersOnly(ByVal varText As Variant) As String
'Takes input and returns only the numbers in the input.  Strips out
'all other characters.  Handles nulls, dates, numbers, and strings.

Const strNumbers As String = "0123456789"
Dim strOut As String
Dim intCount As Integer

  If Len(varText & "") = 0 Then
     strOut = ""

  Else
     varText = varText & ""
     For intCount = 1 To Len(varText)
        If InStr(1, strNumbers, Mid(varText, intCount, 1)) > 0 Then
           strOut = strOut & Mid(varText, intCount, 1)
        End If
     Next intCount
  End If

  fStripToNumbersOnly = strOut

End Function
'---------- Code ends ----------------

> Hi -
>
[quoted text clipped - 7 lines]
>
> Any help would be appreciated!  Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.