Random Sort

  • Thread starter Thread starter Guy
  • Start date Start date
SELECT asa.*
FROM asa
WHERE (((randomizer())=0))
ORDER BY Rnd(IsNull([asa].[AsaID])*0+1);

Change asa to your table name.

For the AsaID field, use a number field. An autonumber field would be best.
 
What funcrion can I use in a query to accomplish a random sort?

Guy
You can use help from a little VBA. Put this little function into a Module:

Public Function RndNum(vIgnore As Variant) As Double
Static bRnd As Boolean
If Not bRnd Then
'Initialize the random number generator once only
bRnd = True
Randomize
End If
RndNum = Rnd()
End Function

Then add a calculated field to your Query by typing

Shuffle: RndNum([fieldname])

in a vacant Field cell, where [fieldname] is any field in
your table - this forces Access to give a different random
number for each record.

Sort the query by Shuffle.
 
Back
Top