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).
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
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.