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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary Key

Status
Not open for further replies.

llldnylll

Technical User
May 21, 2003
89
I have set a AutoNumber for my Primary key.


Is there a way that I can add Letters in front of the numbers?

Instead of having 1,2,3... I want it to be PO1,PO2,P03...
 
Will the prefix always be the same (PO or P0)? If so, and it's for display only, just output ="PO"&RecordID.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
llldnylll

The question you ask is a common one. Review The Ten Commandments of Access

When using the AutoNumbers feature with Access, it is important to note that the purpose of the AutoNumber is to uniquely identify the record. Using AutoNumber to provide a sequential number may result in lost numbers -- will this cause problems? Will people / autidtors get upset with missing PO numbers?

Here are two problems with AutoNumber...
- Autonumber is created by Access with the OnInsert event. This means as soon as you start typing, the autonumber will be by generated using the system tables. If the creation of the record is aborted, the autonumber will be assigned and then discarded. Try it -- start creating a record -- note the autonumber generated -- hit ESC escape key twice -- generated autonumber reverts back to AutoNumber -- now create a second record -- note the gnerated autonumber.
- Secondly, with a multi-user system, there is a chance for a duplicate autonumber being generated. The longer it takes to create the record, the greater the chance two users may generate a duplicate number. Although not directly related to your issue, MichaelRed wrote an FAQ on autonumber - Why AutoNumber shouldn't be used in MultiUser databases (And How to ge the Unique Number)

My approach is to use a Control table that stores and increments the number. The number is generated with the BeforeUpdate event procedure so the risk is low.

Richard

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top