View Single Post
  #6  
Old April 18th, 2010, 06:09 AM posted to microsoft.public.access.queries
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default Extracting the numbers from the Text Field

How about...

Function NumbersInString(Optional WithNumbers As String) As String
Dim Temp As Variant
Dim T As Integer

If IsMissing(WithNumbers) Then
NumbersInString = Null
Else
For T = 1 To Len(WithNumbers)
If IsNumeric(Mid(WithNumbers, T, 1)) Then
Temp = Temp & Mid(WithNumbers, T, 1)
End If
Next
NumbersInString = Temp
End If

End Function

Unlike Ken, I'm far too lazy to rewrite the whole thing... so I modified it
a little and it *seems* to work fine.

?numbersinstring("ABC1234DEF567G89H")
123456789

?numbersinstring()
returns Null

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201004/1