Making text behave as an autonumber

C

Confused Slug

In a table I would like the records in one of the fields to contain the
following;

P00001, P00002 ........ P00999 ........ P09999, P10000

A combination of the letter 'P' and a 5 digit number starting at 00001 and
increasing in value by one with each new record. Its kind of like have an
autonumber field but with the inclusion of the letter 'P' at the start of the
number. The zeros are required following the 'P' so that the number portion
always has five digits.

Any ideas
 
S

Steve Schapel

Slug,

I would certainly use an AutoNumber field for this. Then, when you need
it in the required format (which would be in a Form or Report - how it
appears in a table is normally never relevant because you don't normally
see it), you can set the Format property of the control to this...
\P00000
 
R

Ron2006

Just thoughts:
If you do decide to use an autonumber, remember that it may skip
numbers. Also, if you allow more than one person to add records to the
table, it is possible that numbers may be skipped. If two people start
to add a record, and the first one decides against adding a number, and
aborts the add process, (or their computer goes down or the network
goes down) then that number will be skipped.

If you use autonumber and a number of records are added and then it is
decided to delete those records, those numbers WILL NOT be used again.
This will occur even if no other new records were added.

If you use your own logic to keep track of the number, and the above
happens the numbers will be re-used IF no other new records are added.
If other records were added then the normal processing would not re-use
those numbers, however you could change the numbers for those few
records and therefore put them back in sequence with no skipped
numbers.

If you use your own logic to keep track of the number, you can
physically cause the system to skip a block of numbers, if so desired.
You CANNOT do this if you use autonumber.

Keep it in a control table on an always open form {hidden if you want}
and add 1 to it whenever a new record is created.

Basically, if you want to have ANY control of that number or ever want
to change one for any reason, you DO NOT want to use autonumber.

Ron
 

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