Primary key value

A

acss

I have a number data type in my primary key field and for some reason when i
key in 016 it reverts to the number 16. What can be done so it does not
remove the zero?
 
J

Jerry Whittle

Numbers don't have leading zeros. Therefore you would need to change the
field data type to text. I bet that would be a mistake.

You could format the field to show a leading zero. Do you plan on only have
999 records in that table?
 
S

Steve

If you are using a number data type for your primary key, why not just make
it autonumber and let Access automatically enter your primary key. When you
are typing in the primary key, there is a risk of duplication and typo
errors.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
J

John W. Vinson

I have a number data type in my primary key field and for some reason when i
key in 016 it reverts to the number 16. What can be done so it does not
remove the zero?

It's doing it because AS A NUMBER, 16, 0000016, 016 and 1.6E1 are all *exactly
the same number* (stored as hexadecimal x'00000010').

If you want 016 and 16 to have different meanings then you must not use a
Number datatype, but rather a Text datatype.

If you just want the number to display as three digits with leading zeros, set
the field's Format property to "000".

John W. Vinson [MVP]
 

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