Unique id

Z

Zamin

Hi,

Does any1 know how to use an id consisting of a 1st letter of a persons
firstname and the 1st letter of a person's surname.

E.g. AB001

It should increment values aswell so the next person could be KJ002.
 
J

John Vinson

Hi,

Does any1 know how to use an id consisting of a 1st letter of a persons
firstname and the 1st letter of a person's surname.

E.g. AB001

It should increment values aswell so the next person could be KJ002.

This can be done.
But it's a BAD IDEA!

This kind of "intelligent key" might have made sense years ago, but
now you can simply use a concealed Autonumber field, and display the
person's full name (and perhaps some additional information such as
their department, address, or phone to handle cases where two people
have the same name).

In practice you'll never be able to remember who JV032 is anyway; and
if Janet Helen Vernon gets married and changes her name to Helen
Schmidt, your code becomes completely confused.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
D

DevalilaJohn

So the persons initials are strictly cosmetic.

Set a table with a single column that's an integer. Assuming that you are
starting the system from the beginning, add a row to the table and set the
value to zero. This is the only row you will ever have in the table.

When you need to asign a new id, concatonate the initials and get the
current value in that row. Concatonate it to the initials and then increase
the value in the row by 1.

There are lots of variations you can use to accomplish what you want without
the table, e.g. do a query where you get a Max(right(ID,3)), so take your
pick and good luck.
 
D

DevalilaJohn

Assume you have two fields, strFirstName and strLastName. Putting the
initials together you would code:

strInitials = Left(strFirstName,1) & Left(strLastName,1)

The & does the concatonation.
 
A

angela

??????????????????,??????????????????????????????
John Vinson said:
This can be done.
But it's a BAD IDEA!

This kind of "intelligent key" might have made sense years ago, but
now you can simply use a concealed Autonumber field, and display the
person's full name (and perhaps some additional information such as
their department, address, or phone to handle cases where two people
have the same name).

In practice you'll never be able to remember who JV032 is anyway; and
if Janet Helen Vernon gets married and changes her name to Helen
Schmidt, your code becomes completely confused.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Z

Zamin

Thanks for that, how would I do the increment. So the first person in my
database is ID AB001 and if i add another say a person named Karen Jones
their ID would be KJ002. And where do I code all this coding anyway. Sorry
I am a beginner
 
Top