Remove leading 0's from Text field

B

Bruce

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

thks

Bruce
 
J

John Vinson

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]).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top