Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2005

Tip: Looking for answers? Try searching our database.

How Can Access Generate a Unique Random Positive Number?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BrainLock - 05 May 2005 12:40 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.