G
Guest
Is there an Access function (or combination of functions) that can remove
leading zeroes from a text string?
leading zeroes from a text string?
Is there an Access function (or combination of functions) that can remove
leading zeroes from a text string?
Is there an Access function (or combination of functions) that can remove
leading zeroes from a text string?
John Vinson said:Is there an Access function (or combination of functions) that can remove
leading zeroes from a text string?
If it's numeric, use Val([fieldname]), or CStr(Val([fieldname])) to
get back to a string.
If it's text, or mixed numeric and text, after the zeros, you'll need
a little VBA function. Here's a recursive one off the top of my head,
test it first:
Public Function StripZeros(strIn As String) As String
If Left(strIn, 1) = "0" And Len(strIn) > 1 Then
StripZeros = StripZeros(Mid(strIn, 2))
Else
StripZeros = strIn
End If
End Sub
John W. Vinson[MVP]
John .. you did recursion ... eeewww!!! LOL!
If it's text, or mixed numeric and text, after the zeros, you'll need
a little VBA function. Here's a recursive one off the top of my head,
test it first:
Tom Lake said:Why not use LTrim?
Tom Lake
OK, I know why. I thought of spaces while reading Zeros. Never mind!
LTrim(Str(Val(n)))
should work, though.
redundant since Val() already does the trimming... and it will fail
for input data such as "0000A32KW". The OP hasn't posted back with
more details so we may never know!
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.