DEALING WITH ZERO'S

J

John

I appreciate anyones feedback with this. Many times I
create databases that requires zero's as leading numbers.
I.E. 0001234. Every time you enter the leading zeros they
disappear. I want them to stay. I tried formatting the
field as text but you cannot sort a text format properly.
Any ideas.
 
L

Larry Linson

Showing leading zeros is just a matter of using the Format function. Numeric
values are stored in binary (except for Currency) on the computer and the
leading zeros you see are in character form.

The zero in the format template indicates "display a zero if there is not a
non-zero value in this digit" and works for either leading or trailing
zeros. Try this in the Immediate Window

? Format(1.1,"0000.00")
0001.10

Larry Linson
Microsoft Access MVP
 
G

Guest

One way to handle this would be to create two fields. One as a text field with the leading zeros and another as a numeric field (index) to handle the sort.
 
J

John Vinson

I appreciate anyones feedback with this. Many times I
create databases that requires zero's as leading numbers.
I.E. 0001234. Every time you enter the leading zeros they
disappear. I want them to stay. I tried formatting the
field as text but you cannot sort a text format properly.
Any ideas.

Eh? a Text field with leading zeros DOES sort correctly.

Just use Text, I'd suggest.
 

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