Adding Zeros

By blacknred0 ·
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.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

use format in properties of text box

by john.a.wills In reply to Adding Zeros

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

Collapse -

If they have zeros on the front they are not numbers

by Tony Hopkinson In reply to Adding Zeros

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


Collapse -

"Display leading zero's"

by jdclyde In reply to Adding Zeros

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.

Related Discussions

Related Forums