How to autogenerate an alphanumeric code?

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?
 
M

Michael Keating

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.
 

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