Leading Zeroes

G

Gregg

I am appenidng data from one table to another and am
trying to remove leading zeroes so that data that looks
like "000038150" appends as "38150". How do I do this?
Does it matter what type of field this is (Text, Number,
etc.)?

Thanks for you help.
 
J

John Spencer (MVP)

Well, number fields are stored without leading zeroes.

You could use a calculated field to get the desired value.

Val(SomeField) should strip off any leading zeroes in a string.
 
J

John Vinson

I am appenidng data from one table to another and am
trying to remove leading zeroes so that data that looks
like "000038150" appends as "38150". How do I do this?
Does it matter what type of field this is (Text, Number,
etc.)?

Yes, it does matter. A Number datatype is stored as binary bits, not
as decimal digits; it can be formatted to display leading zeros but
they're not stored. If you won't be doing math with the field, use
Text; if you will, store the result in a Long Integer number field.

Or you can store it as Text with the leading zeros trimmed off by
appending a calculated field:

CStr(CLng([fieldname]))

to convert the text digits to a Long and then back to string, losing
the zeros in the process.
 

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