Randomly generated data

J

Jim/Chris

Yes in the debug window type randomize.
In your query
add your name field in the first column
Add Shuffle: RndNum([name]) in the second column
run the query and sort on the Add shuffle field.

You will notice that every time you run this query the
names appear in a different order. If you are running a
drawing you could take the first entry or any entry. The
important thing to remember is every time you run it the
order will be random. Isn't that what you want?

Jim
-----Original Message-----
Jim...thanks for the response. I'm afraid that I'm quite
new at this, so I'm not sure what to do next. I got the
query part OK (I think), but I don't know about issuing a
Randomize command. I did the Ctrl+G and got a "Debug"
window...then what? Do I just type in "Randomize"?
Where? Then what? What about the query? Sorry for being
so helpless with this.

Susan
-----Original Message-----
Try this. I got it from Allen Browne

Assuming you have a numeric primary key named (say)
QuestionID, type this
into the Field row of a query:
RandomNum: Rnd([QuestionID])

Sort the query on this field, and your questions will come
up in random
order.

Note that you need to issue a Randomize command once in
your session for
this to work. You can do that when the database opens, or
just go to the
Immediate window (Ctrl+G) and enter:
Randomize

The Rnd() function does not actually do anything with your
primary key, but
unless you pass some value in from the query, Access
doesn't bother calling
the function so you don't get the random values.

Jim
-----Original Message-----
We have a staff database from which we will be drawing
names for a contest. Is there some way I can get Access
to randomly select from the over 100 names? I'm trying to
avoid having to print out a list, cut out the individual
names, and pick one from a hat!
.
.
.
 
S

Susan

Jim - thanks heaps! It worked like a champ...will surely
save me much aggravation, since we will be doing a monthly
drawing from the names of all our (currently) 260 staff
members! I appreciate the help!

Susan
-----Original Message-----
Yes in the debug window type randomize.
In your query
add your name field in the first column
Add Shuffle: RndNum([name]) in the second column
run the query and sort on the Add shuffle field.

You will notice that every time you run this query the
names appear in a different order. If you are running a
drawing you could take the first entry or any entry. The
important thing to remember is every time you run it the
order will be random. Isn't that what you want?

Jim
-----Original Message-----
Jim...thanks for the response. I'm afraid that I'm quite
new at this, so I'm not sure what to do next. I got the
query part OK (I think), but I don't know about issuing a
Randomize command. I did the Ctrl+G and got a "Debug"
window...then what? Do I just type in "Randomize"?
Where? Then what? What about the query? Sorry for being
so helpless with this.

Susan
-----Original Message-----
Try this. I got it from Allen Browne

Assuming you have a numeric primary key named (say)
QuestionID, type this
into the Field row of a query:
RandomNum: Rnd([QuestionID])

Sort the query on this field, and your questions will come
up in random
order.

Note that you need to issue a Randomize command once in
your session for
this to work. You can do that when the database opens, or
just go to the
Immediate window (Ctrl+G) and enter:
Randomize

The Rnd() function does not actually do anything with your
primary key, but
unless you pass some value in from the query, Access
doesn't bother calling
the function so you don't get the random values.

Jim

-----Original Message-----
We have a staff database from which we will be drawing
names for a contest. Is there some way I can get Access
to randomly select from the over 100 names? I'm
trying
to
avoid having to print out a list, cut out the individual
names, and pick one from a hat!
.

.
.
.
 

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