Generate Unique User ID

  • Thread starter Thread starter Alex T
  • Start date Start date
A

Alex T

I am trying to work with imported data and generate a unique username
to store in a "users" table. I need this to work much like an
interactive username selection on a typical web site. That is, pick a
username, check to see if it's used, if so, modify it (like add a
number to the end), then look again until the user ID is unique.

There would be a table with the list of current user IDs that the
process can check against to see if the imported user ID is unique.
This table would be updated as each new user ID is added.

The real difference between this and the web site example is that the
query has to pick a different user ID if the one it tried is in use
rather than the user doing this.

Has anyone done anything like this and perhaps has some code they can
share?

Thanks!
Alex
 
Given:
Chr$(49) = "1"
Chr$(57) = "9"

Asc("1") = 49
Asc("9") = 57

Thus:
When you find that a Username exists, you then have to look to see what the
last character is. If it's ASC() value is not between 49 and 57, then add a
"1" to it. Done.

If it is between the range, then you need to remove the previous char,
increase the ascii value by 1, then add it to the end of th string. Unless
of course the value is 9, then you need to do something else, however you
want to handle that situation. (Go Hexadecimal or to the value of 10??)
 
Back
Top