Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating Random numbers in a field 1

Status
Not open for further replies.

jeevenze

Technical User
Mar 13, 2001
62
US
I have a table with the following fields set up, username, password and userID in Access2000.

Is there a way I can set the userID field to generate a random number when I insert a new record?

I currently have it set to auto_increment but ideally I want it to have a non duplicated auto random number that is at least 10 digits long.

Thank you in advance to anyone who helps me.

Jeevenze
 
Ouch, your users are going to hate you. I think you are going to make more work for yourself then what it is worth.

But, if you were going to do this, I would have a table with two columns. The first would be your unique ID's (I suggest an autonumber) and the second would be a IsUsed field (boolean). I would start out with a script that would prepopulate the table with 9,999,999,999 records to get all of the numbers filled and set the IsUsed field to false. Then, as you create a new user, I would pull a record from here that still had the IsUsed set to false.

You can look in the help for the Random functions and maybe the GetRows method to help.

Good Luck. Lock your door. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top