Solved PK Autonumber... but with Text (1 Viewer)

Da_Panda

New member
Local time
Today, 10:07
Joined
May 29, 2020
Messages
3
Hello,

Am creating a database, and about the PK. The standard, and very easy/comfortable way, is to use Autonumber (1, 2, 3,...). Then one could also just use Text, but one have to manually write it in.

Would then hear if its possible to a somewhat combination? And how?
eg. I'm thinking of a schema like: DOC001, DOC002, DOC003. Where the text body then stay the same, but then every time one make a new Record, the like with Autonumber, the number would then change to the next one in line...
 

Minty

AWF VIP
Local time
Today, 09:07
Joined
Jul 26, 2013
Messages
7,092
You can format the auto number to display with a prefix.
In the format property simply add "DOC"0000
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 09:07
Joined
Jul 9, 2003
Messages
11,668
This is done, but it does suffer from a couple of problems. The first one is, if data entry is started, but then aborted, that particular auto number is lost. You cannot ever use the deleted Auto number ID, it's gone for good as far as I'm aware, although I always dubious about making such a statement because somebody usually finds a workaround! But I'm pretty confident in this case. So now you have a missing number in your list.

An alternative is to have a separate number field and every time you add a new number to it, you find and the existing maximum number and add 1 to it and use it for your new record then you can be sure of a continuous list of numbers, 1 2 3 4 5 6 etc
 

Minty

AWF VIP
Local time
Today, 09:07
Joined
Jul 26, 2013
Messages
7,092
Unless its an accounting package and an uninterrupted sequence is an absolute requirement, I personally don't see an issue with a missing number if it's simply a unique reference.
Using a DMax approach works but is fraught with dangers with multiple users especially over slower network connections.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:07
Joined
Feb 19, 2002
Messages
29,021
If everything is "doc", then the text serves no purpose.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom