Random Sort Order

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hello,

I was wondering if there was a way to randomize the sort
order of a recordset during or after its creation. If
there is does this order stay consistent until the
recordset is destroyed (I know it would change it I were
to change the sort order)?

Also, the sort order would have to be diffent (completely
random) each time the recordset was created/sorted. I have
been playing aroung with the Rand function and its seems
to only randomize the first time it is used and then is
using the same results/order there after.

Thanks all,
David
 
Rnd() produces consistent results only if you do not issue a Randomize
first.

I seem to recall that you need to pass some value into the Rnd() function in
order to get a different result on each row. E.g if you have a primary key
named "ID"
Rand([ID])

If you require consistent results, it may be worth writing a temp table
containing just two fields:
- the key value of your table, and
- a random value to sort on.
Then create a query combining this table with your real one, and you can do
as you like, and know the results will remain consistent until you
repopulate the temp table.
 
Back
Top