Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add leading Zeros back in

Status
Not open for further replies.

bkf7911

MIS
Mar 20, 2007
83
US
I'm getting a data feed that I need to bring to access and compare one field to another to validate data.

Unfortunately, any leading zeros are removed from the data field, but are still available in the validation table in Access.

I can't change the validation table, and i can't just automatically add in X number of zeros, since the number of leading zeros isn't always the same.

How can I fix the values in teh data field to add in X number of zeros until the length of the field is 8?
 
select right('00000000' & myNumberCol, 8)

should do the trick. I am pretty sure that Access will implicitly cast myNumberCol to a string type when you try to concatenate, if it doesn't you will need to use CStr(myNumberCol).

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Have a look at the Format function:
PaddedNumber: Format([data field],'00000000')

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top