Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Random Number generation

Discussion in 'Information Technology' started by joshroberts, Jul 28, 2006.

  1. joshroberts

    joshroberts
    Expand Collapse
    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.
     
  2. Loading...

    Similar Threads Forum Date
    Is miracle less about randomness and more about faith ? Intellectual Articles Oct 14, 2015
    Christianity Pope: Humanity isn't random product of evolution Interfaith Dialogues Apr 24, 2011
    Random Process in Sikhism Sikh Sikhi Sikhism Aug 20, 2008
    Random of Act of kindness... Inspirational Stories Mar 25, 2008
    Conspriacy theory ! Random thoughts Sikh Youth Oct 2, 2006

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    Randomize before you use Rnd().

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "joshroberts" <joshroberts@discussions.microsoft.com> wrote in message
    news:72DAAE76-9659-408C-B4BE-F1C3E8DFC2B7@microsoft.com...
    >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.
     
  4. Al Camp

    Al Camp
    Expand Collapse
    Guest

    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.
    --
    hth
    Al Camp
    Candia Computer Consulting - Candia NH
    http://home.comcast.net/~cccsolutions

    "joshroberts" <joshroberts@discussions.microsoft.com> wrote in message
    news:72DAAE76-9659-408C-B4BE-F1C3E8DFC2B7@microsoft.com...
    >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.
     
  5. joshroberts

    joshroberts
    Expand Collapse
    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?

    "Allen Browne" wrote:

    > Randomize before you use Rnd().
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "joshroberts" <joshroberts@discussions.microsoft.com> wrote in message
    > news:72DAAE76-9659-408C-B4BE-F1C3E8DFC2B7@microsoft.com...
    > >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.

    >
    >
    >
     
  6. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    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.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "joshroberts" <joshroberts@discussions.microsoft.com> wrote in message
    news:78BF5FCF-6A54-4A87-BA11-71057DF75157@microsoft.com...
    >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?
    >
    > "Allen Browne" wrote:
    >
    >> Randomize before you use Rnd().
    >>
    >> "joshroberts" <joshroberts@discussions.microsoft.com> wrote in message
    >> news:72DAAE76-9659-408C-B4BE-F1C3E8DFC2B7@microsoft.com...
    >> >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.
     
  7. jean-pierre.vasseur

    jean-pierre.vasseur
    Expand Collapse
    Guest

    "joshroberts" <joshroberts@discussions.microsoft.com> a écrit dans le message de news: 72DAAE76-9659-408C-B4BE-F1C3E8DFC2B7@microsoft.com...
    >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.
     
  8. Al Camp

    Al Camp
    Expand Collapse
    Guest

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

    "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
    news:OoZIciSmGHA.4268@TK2MSFTNGP05.phx.gbl...
    > 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.
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "joshroberts" <joshroberts@discussions.microsoft.com> wrote in message
    > news:78BF5FCF-6A54-4A87-BA11-71057DF75157@microsoft.com...
    >>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?
    >>
    >> "Allen Browne" wrote:
    >>
    >>> Randomize before you use Rnd().
    >>>
    >>> "joshroberts" <joshroberts@discussions.microsoft.com> wrote in message
    >>> news:72DAAE76-9659-408C-B4BE-F1C3E8DFC2B7@microsoft.com...
    >>> >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.

    >
    >
     
  9. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

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

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Al Camp" <anon@anon.net> wrote in message
    news:udKrQ0emGHA.2204@TK2MSFTNGP03.phx.gbl...
    > Allen,
    > I've never used Random Autonumber. Is there a possibility of dupes with
    > that method?
    > Thanks,
    > Al Camp
     
  10. Al Camp

    Al Camp
    Expand Collapse
    Guest

    OK Allen. Thanks for that info.
    Al Camp

    "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
    news:OeSZQufmGHA.4212@TK2MSFTNGP03.phx.gbl...
    > Access should not give you dupes, but that feature is really designed for use with GUIDs
    > (Globally Unique IDentifiers, called Replication ID.)
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "Al Camp" <anon@anon.net> wrote in message
    > news:udKrQ0emGHA.2204@TK2MSFTNGP03.phx.gbl...
    >> Allen,
    >> I've never used Random Autonumber. Is there a possibility of dupes with that method?
    >> Thanks,
    >> Al Camp

    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page