Randomly ordered recordset

B

Brandon Taylor

Hello everyone,

I need to select 10 unique records from an Access DB and order them
randomly. I've searched high and low online for an example of how to
randomize a recordset this way, but can't find an example that quite does
what I want. Opening the recordset isn't a problem, it's the randomization.

Can someone please point me in the right direction?

Thanks in advance,
Brandon
 
T

Tom Gahagan

Hi Brandon.....

Help us understand why, If you have only 10 records that you have uniquely
selected from a database in your recordset, do you need to have them show up
in a random order?

Is the order they come in from the queary unacceptable?

If guess one way would be to have a random number generator generate a
number, assign it to a variable and see if the number is between 0 and 9 or
1 and 10 depending on how the recordset assigns record numbers and then get
that record and then repeat the process until all 10 records are displayed.
BUT WHY would you go to that trouble, time to complete the randomizing,
etc?????

Anyway..... best of luck with your problem.

Tom Gahagan
 
J

Jens Peter Karlsen[FP MVP]

A recordset as such can't be random. You can sort it in different ways
but that's it.
To accomplish what you are after, you could place the result in an array
and then use random numbers to decide in what order you want the results
presented. Remember to exclude numbers when you have used them.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 

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