Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ranomize Numbers

Status
Not open for further replies.

Hokis

Technical User
May 21, 2007
51
US
Hi guys,
I have a table that has 10,000 field, with different 20 numbers in it, i want to randomize that column, but i can't seem to be able to. I don't want to sort (ascending or descending), i just want to randomize sorting.
Is there a way???
Thank you
Hokis
 
This is from Access help. It may give you a starting point.

Randomize Statement Example

This example uses the Randomize statement to initialize the random-number generator. Because the number argument has been omitted, Randomize uses the return value from the Timer function as the new seed value.

Dim MyValue
Randomize ' Initialize random-number generator.

MyValue = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.

 
The key here is that Rnd() by itself will only fire at the beginning of the query. You need to pass the Rnd function a unique value

This works
SELECT tblOne.id, Rnd([id]) AS RandomSort
FROM tblOne
ORDER BY Rnd([id]);

This won't
SELECT tblOne.id, Rnd() AS RandomSort
FROM tblOne
ORDER BY Rnd();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top