delete text in a row

  • Thread starter peljo via AccessMonster.com
  • Start date
P

peljo via AccessMonster.com

Is it possible to delete by code all the data in the table field that are not
numerical ? For example one row in the field F7 consists of the following
Invoice 4567999
Is it possile to delete the letters invoice in this row ?
 
J

John Spencer

Just to save you the trouble of creating the function.

Public Function fStripToNumbersOnly(ByVal varText As Variant)
'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 = Null

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

If Len(strOut) > 0 then
fStripToNumbersOnly = strOut
Else
fStripToNumbersOnly = Null
End if

End Function



John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
Top