Remove leading 0's from Text field

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I have a text field with leading zeros. Is there a way to
strip these off in Access 2000.

thks

Bruce
 
I have a text field with leading zeros. Is there a way to
strip these off in Access 2000.

thks

Bruce

One sneaky way: run an Update query updating the field to
CStr(CLng([fieldname]).

If the "numbers" have no decimal places and fewer than nine digits it
should work fine.

More tedious but more general: write a VBA function such as

Public Function StripZero(strIn As String) As String
Dim iPos As Integer
StripZero = ""
For iPos = 1 to Len(strIn)
If Mid(strIn, iPos, 1) <> 0 Then
StripZero = Mid(strIn, iPos)
Exit Function
End If
Next iPos
End Function

and update the field to StripZero([fieldname]).
 
Back
Top