DEALING WITH ZERO'S

  • Thread starter Thread starter John
  • Start date Start date
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.
 
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
 
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.
 
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.
 
Back
Top