Random Number generation

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.
 
A

Al Camp

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.
 
G

Guest

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?
 
A

Allen Browne

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.
 
J

jean-pierre.vasseur

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.
 
A

Al Camp

Allen,
I've never used Random Autonumber. Is there a possibility of dupes with that method?
Thanks,
Al Camp
 
A

Allen Browne

Access should not give you dupes, but that feature is really designed for
use with GUIDs (Globally Unique IDentifiers, called Replication ID.)
 
A

Al Camp

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.)
 

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.

Ask a Question

Top