Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert leading zeros into Auto-number field?

Status
Not open for further replies.

Turb

Technical User
Feb 11, 2003
154
US
Does anyone know how to insert leading zeros into an auto-number field or even if it can be done?
Any help appreciated!
Thanks,

Turb

Ind. Engineering Tech.
 
Let's try to think of Autonumber as a datatype which you cannot change (not true, but ...), so you cannot insert leading zeros to it. However you can format it to have leading zeros, either in the format property of the field, or the controls where you use it, by for instance enter the zeros in the format property.

Though - most of us, I believe, think that if you're using an autonumber, it's better left unseen by the user, and that something like formatting an autonumber, is assigning buisiness meaning to it, which I believe most of us will recommend against.

Roy-Vidar
 
Roy,
Thank you for your response.
My reasoning in using the auto-number field is simply to place a unique ID on each record in the table (I have no form over-laying the table). I was hoping to be able to create a unique ID in a format of 000001 - 999999 for my records.
Can I create something else, for use on the table directly, in place of the auto-number field?


Turb

Ind. Engineering Tech.
 
I agree with Roy about the appropriate use of Autonumber fields (i.e. not seen by the user; for internal use only.)

The autonumber field is a unique ID for the record ... regardless of how you format it. If you want the Autonumber to be displayed with your leading zeros then provide a query of the form
Code:
Select Format(AutoNumberField, "000000") As [ID], ...
From myTable
 
Turb,

I think this topic has been addressed before in TT. Try a TT search and then post back.

Best of luck!
Tim

[blue]______________________________________________________________
I love logging onto Tek-Tips. It's always so exciting to see what the hell I
said yesterday.
[/blue]
 
This post may be of interest. Look at fneily's post in the 2nd and 3rd paragraphs on how to make you own unique autonumber.

thread181-1163750
 
Everyone,
Thank you so much for your input!
I believe I have the answer I was looking for now.
The pros here at Tek-tips are the best!
Thanks again,

Turb

Ind. Engineering Tech.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top