Re: Generating Random Numbers...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rob Oldfield (blah_at_blah.com)
Date: 01/17/05

  • Next message: KrazyRed: "Questionnaire Problems Using Forms & Subforms"
    Date: Mon, 17 Jan 2005 21:07:59 -0000
    
    

    Rather than doing the generation on the fly, it'd be better to just create
    an initial table containing 1-999 in a random order, then just read those
    numbers in order.

    The word 'better' is, as Martin suggests, a relative term. You should tell
    your management team that their plan is ludicrous (unless there are other
    reasons you don't mention).

    "Martin J" <anonmous@nospam.com> wrote in message
    news:2AF959BB-9F19-494B-A9A6-5FAD120EFC1D@microsoft.com...
    > to use random it would look like this
    > dim job as int
    > Randomize
    > job = Rnd() * 1000
    > To check if its a double
    > if dlookup([job],[table],"[job]=" & job) is null then add record
    > this is how it would be done. I personally hate doing it this way bec. why
    > use random numbers as keys? At least use counting numbers up to 999. Think
    > about what is going to happen when there are few keys left. It might take
    a
    > while for the program to find a key for you. You also have to make sure
    not
    > all the keys are used with a dcount() statment otherwise you'll be in an
    > infinite loop. With counting numbers its very simple
    nz(dmax(job,table),0)+1
    > if <1000 then add record. In all these cases the 05 should be added on the
    > form and not be saved with the field.
    >
    > HTH
    > Martin J
    >
    > "Brad Pears" wrote:
    >
    > > The management team has come up with a plan to generate random job#'s
    for
    > > each home that we build - However, the first two digits will be the year
    the
    > > job came in i.e. this years jobs will be starting with "05" and the
    next
    > > three digits will be the random number I generate.
    > >
    > > This number is stored in our Access DB and I must make sure that each
    time a
    > > new random number is generated, that it does not already exist in the
    db -
    > > so will have to do a quick lookup.
    > >
    > > Does anyone have any code to randomize numbers? I want to generate a 3
    > > digit number.
    > >
    > > Thanks,
    > >
    > > Brad
    > >
    > >
    > >


  • Next message: KrazyRed: "Questionnaire Problems Using Forms & Subforms"

    Relevant Pages

    • Re: Trying to use sets for random selection, but the pop() method returns items in order
      ... I also tried using a dictionary, with keys from 1 to 10, and also got ... The keys in a dict or set are not in random order, ... they are in hash key order modulo the size of the hash. ...
      (comp.lang.python)
    • Re: Generating Random Numbers...
      ... an initial table containing 1-999 in a random order, ... At least use counting numbers up to 999. ... > about what is going to happen when there are few keys left. ... >> three digits will be the random number I generate. ...
      (microsoft.public.access.formscoding)
    • Re: keypress predictor
      ... user to press keys in what feels to him to be a random order. ... writing a little Basic program to put letters on the screen and have ... and see what letters or numbers top the list. ...
      (comp.lang.basic.misc)
    • Re: Set priority of Run key
      ... random order. ... TECH ...
      (microsoft.public.vb.general.discussion)
    • Re: Memorisable/handwriteable/typeable key styles
      ... >>> all of which have four letters. ... > with random digits. ... those keys are too long - so we use letter/digit ... Not for secret keys, ...
      (sci.crypt)