How to autogenerate an alphanumeric code?

  • Thread starter Thread starter Bam Bam
  • Start date Start date
B

Bam Bam

Hi All,

I'm building a 'Clients' database where each 'Client' has many associated
'Job Specifications' held in a seperate table. To formulate an alphanumeric
code for each 'Job Spec' the particular Clients 3 letter prefix(e.g. TOS for
Toshiba, the clients prefix is stored in their record in the 'Clients'
table) needs to be combined with a number to make that Job Spec unique to
the Client and the database. Example Job Spec numbers may be TOS1, TOS2,
TOS3 for Toshiba and MTR1, MTR2, MTR3 for Motorola. Seeing as the Clients
prefix will always be available in the clients record and each alphanumeric
code can be stored in the Job Specs table, what is a good way to generate
these alphanumeric codes?
 
Bam Bam said:
Hi All,

I'm building a 'Clients' database where each 'Client' has many associated
'Job Specifications' held in a seperate table. To formulate an alphanumeric
code for each 'Job Spec' the particular Clients 3 letter prefix(e.g. TOS for
Toshiba, the clients prefix is stored in their record in the 'Clients'
table) needs to be combined with a number to make that Job Spec unique to
the Client and the database. Example Job Spec numbers may be TOS1, TOS2,
TOS3 for Toshiba and MTR1, MTR2, MTR3 for Motorola. Seeing as the Clients
prefix will always be available in the clients record and each alphanumeric
code can be stored in the Job Specs table, what is a good way to generate
these alphanumeric codes?
Hi

Personally I believe that simple is best.

I'd store the last job spec number for each client in the clients table,
that way you just retrieve the code and number, increment the number and use
it, then store it back into the clients table if the addition of the job
spec was successful.

This will make life much easier later on, you'll avoid having to find the
last job spec record and extract the number from the code.

HTH

MFK.
 
Back
Top