Hi John,
There is a good reason for this system, it is used in the golfworld over
here.
app. 370.000 people use it in one way or another.
its an easy way too for everybody and it is printed on their personal card.
They use this code as logincode (together with a password)
So its not for the backend of my database but for a login methode for all
users.
Ok... ASSSUMING (and it's a big assumption!) that you only want the code to be
unique for that subset of golfers entered in your database (i.e. that if you
are BECK1 and you aren't concerned about Sid Beckwith in Galveston, TX being
another BECK, then you can do this with some code. It's a LOT easier if you
use two fields - one for the text portion, and a Number... Long Integer field
- let's call it NameSeq - for the number. You can concatenate them for display
purposes with an expression like
UCase(Left([LastName] & " ", 4)) & [NameSeq]
This will show "Beckwith" as "BECK4" and Wu as "WU31", or whatever that
person's sequence number is.
You will also need some (reliable) way of identifying which names are in fact
new to the system. You obviously cannot use just the last name - they're not
unique; and you have no a priori way to know that John Vinson isn't already
one of the dozen VINS in your database (vins are often tres ordinaire <g>).
That said, if you are entering a new golfer into the database (and you know
that they are new!) you could use an expression like
NZ(DMax("[NameSeq]", "[YourTableName]", "LastName LIKE " &
Left(Me!txtLastName, 4) & "*")) + 1
to find the maximum existing value of NameSeq for the LastName in the textbox
txtLastName on your form and add 1 to it; the NZ() will cause names completely
new to the system to get 1 as NameSeq.
There's more to it than this of course (e.g. what do you do when PHIL32, Janet
Phillips, marries and changes her last name to Robertson?) but it should give
you a start.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also
http://www.utteraccess.com