Re: Generating Random Numbers...
From: Rob Oldfield (blah_at_blah.com)
Date: 01/17/05
- Next message: MikeZz: "Help: Apply Form Filter using checkbox & linked table"
- Previous message: Sprinks: "RE: Generating Random Numbers..."
- In reply to: Martin J: "RE: Generating Random Numbers..."
- Next in thread: Sprinks: "RE: Generating Random Numbers..."
- Messages sorted by: [ date ] [ thread ]
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: MikeZz: "Help: Apply Form Filter using checkbox & linked table"
- Previous message: Sprinks: "RE: Generating Random Numbers..."
- In reply to: Martin J: "RE: Generating Random Numbers..."
- Next in thread: Sprinks: "RE: Generating Random Numbers..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|