|
TexasWebDevelopers -> RE: Random Results in A Searchy Query HELP!! (10/29/2009 9:21:28)
|
Randomizing record retrieval is a bit more complicated than it might seem at first blush. First, you need to find a cound of the records..you cannot randomize without that information: cnt1 = cnt rndMax = cnt If CInt(5) < cnt Then cnt1 = CInt(5) End If Then we need to create a random number based on the count: RndNumber = Int(Rnd * rndMax) Next its time to randomize the results If (InStr(1, str1, "," & RndNumber & "," ) = 0) Then str1 = str1 & RndNumber & "," cnt1 = cnt1 - 1 Rs.MoveFirst Rs.Move RndNumber str = str & Rs("id") & "," End If Loop The full code and example are here: http://www.texaswebdevelopers.com/examples/retrieverandomrecords.asp
|
|
|
|