I need access2003 to generate a unique random number that is positive and at
least 6 digits in length
Rick Brandt - 05 May 2005 12:47 GMT
>I need access2003 to generate a unique random number that is positive and at
> least 6 digits in length
For what purpose? I'm wondering why it has to be positive and if it really has
to be numeric. You can have Access generate a random AutoNumber and display it
as a Hexadecimal value. That gives you a consistent number of characters that
are random and no negative sign (even when the underlying value is negative).
Would that work?

Signature
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Tim Ferguson - 05 May 2005 20:35 GMT
> I need access2003 to generate a unique random number that is positive
> and at least 6 digits in length
You don't say what the maximum length is, and whether leading zeroes
count toward the digits. Making assumptions, and applying some primary
school maths:
Largest number 8 digits = 99999999
Smallest number = 100000
Range = 99999999 - 100000 + 1 = 99900000
So we start with a number n: 0 <= n < 99900000
and then add on the 100000 to get back to the desired range:
n = Int(CDbl(99900000) * Rnd()) + 100000
Hope that helps
Tim F