Sorting in Access

W

Walt

Is there any way to do a random sort in Access? I would
want to sort on a different key each time I do a random
sort.
 
A

Allen Browne

Create a query into the table(s) you wish to sort randomly.

Enter this into the field row:
Rnd([ID])
where "ID" represents the name of the primary key.

In the Sorting row under this field, choose "Ascending".

In the Immediate Window (Ctrl+G), enter:
Randomize
and press enter.

This works by generating a random number at each row, and using it for
sorting.

The Rnd() function does not actually do anything with the numeric value past
in, but the query optimizer does not make the function call at each row
unless you pass in a changing number.

Unless you issue the Randomize command when you start Access, it will return
the same series of numbers each time.
 

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