Primary key value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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?
 
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)
 
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]
 
Back
Top