View Single Post
  #9  
Old April 21st, 2010, 04:08 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Extracting the numbers from the Text Field

John Spencer wrote:

Try this modification if you are passing in values that might be null

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

If IsNull(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



I wonder if using Like "#" is faster or slower than
IsNumeric? At least Like generalizes to other sets of
characters more easily.

--
Marsh
MVP [MS Access]