Random Number generation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form set up to generate a random ID number for every entry. We
would like to keep this number random however whenever I exit Access the
random number stream resets at the beginning. Is there any way to keep the
random number stream from resetting? Thanks.
 
Josh,
Check out the Randomize statement in Help. Run it just before creating the Rnd value.
But... Access provides for a Random Autonumber (rather than Incremental). That might
be an easier solution.
 
I thought of that and it certainly is a possibility but since this is my
primary key I'm still worried about duplicates at some point. Is there any
other way to do this aside from making my random number huge to reduce the
chance of duplicates?
 
You do need to Randomize.

Dupes are possible, so I imagine what you would do is to use values in the
full range of a Long Integer, and test if the number exists before trying to
assign the new record.
 
joshroberts said:
I have a form set up to generate a random ID number for every entry. We
would like to keep this number random however whenever I exit Access the
random number stream resets at the beginning. Is there any way to keep the
random number stream from resetting? Thanks.
 
Allen,
I've never used Random Autonumber. Is there a possibility of dupes with that method?
Thanks,
Al Camp
 
Access should not give you dupes, but that feature is really designed for
use with GUIDs (Globally Unique IDentifiers, called Replication ID.)
 
OK Allen. Thanks for that info.
Al Camp

Allen Browne said:
Access should not give you dupes, but that feature is really designed for use with GUIDs
(Globally Unique IDentifiers, called Replication ID.)
 
Back
Top