Question Locked

Adding Zeros

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

i am currently working on access database and i move couple of numbers that contains zeros on front.

eg. 00015489

now "000" is gone. my current output is 15489. is there a way in access for me to add those "000" on front that are missing?

thank you in advance.

4 replies

by john.a.wills

00000000 is the format you want. For more format possibilities, see "Format Property - Number and Currency Data Types" under the Help pull-down.

by tony hopkinson

they are strings.

Which way you go depends on whether you need them stored with the leading zeros.

If you can get away with just displaying like that, and you need to do math or data entry validation. Then a display format will work.

If Mr wills idea of using display format doesn't suit.

The sql way of turning 15489 into '00015489' is

Select Replicate('0',8 - DataLength(Convert(VarChar(8),15489))) + Convert(VarChar(8),15489)

You could also do it with the VB style functions such as Length, and CStr, though if you ever choose to use a full DBMS, they will cause you problems

HtHs

by jdclyde

look for that option, it is in some packages.

Don't know which version of access you are working with, so can't say for sure what you will find, or where to look other than format of the field.

This discussion is closed to new replies.