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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate Random #s in Access??? 2

Status
Not open for further replies.

jeevenze

Technical User
Mar 13, 2001
62
0
0
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
 
how about something like this
SELECT Int(Rnd()*9+1) & Int(Rnd()*9+1) & Int(Rnd()*9+1) & Int(Rnd()*9+1) & Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1) AS Expr1
FROM someTable
where criteria

Pete
_____________
Real programs don't eat cache


 
Is there an expression I can enter in the 'default value' (when you view a table in design view) that would create the random number?
Your expression:
Int(Rnd()*9+1) & Int(Rnd()*9+1) & Int(Rnd()*9+1) & Int(Rnd()*9+1) & Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1)& Int(Rnd()*9+1)
works when data is inputed from Access, but when I try and input from a web browser using ultra dev I don't get a random number.
 
Did you set your default in the UserID field to 'random number'? I know it works in Access 97 but never really played that much with it in 2000.
 
yup,
It was a lot easier than coming up with an expression. In access 2000 when you pick the field type as an 'auto-number' the default is auto-increment but there's an option where you can set it to random numbers.

Jeevenze
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top