Discussion on:

Message 8 of 9
0 Votes
+ -
RE: How do I... Retrieve a random set of records in Microsoft Access?
HI
Thank you for your article! For the first 4-5 listings, it worked well, but after it keeps showing the same values for me..

my query:

Public Function GetRandomValue(PIC_ID)

Randomize

GetRandomValue = Rnd(1)

End Function


set rsTypes = Server.CreateObject("ADODB.Recordset")
rsTypes.ActiveConnection = MM_connDUgallery_STRING

rsTypes.Source = "SELECT TOP 1 PICTURES.PIC_ID, PICTURES.PIC_IMAGE, PICTURES.PIC_TYPE, PICTURES.PIC_VOTE_COUNT, PICTURES.PIC_VOTE_VALUE, IIf([PICTURES]![PIC_VOTE_COUNT]=0,[PICTURES]![PIC_VOTE_COUNT]=1,[PICTURES]![PIC_VOTE_VALUE]/[PICTURES]![PIC_VOTE_COUNT]) AS Kif1, PICTURES.PIC_NAME, PICTURES.PIC_APPROVED, Rnd([PIC_ID]) AS Kif2 FROM PICTURES WHERE (((PICTURES.PIC_APPROVED)=1)) ORDER BY Rnd([PIC_ID]); "

rsTypes.CursorType = 0
rsTypes.CursorLocation = 2
rsTypes.LockType = 3
rsTypes.Open()
rsTypes_numRows = 0


--------> The PIC_ID is always > 0 ! But I also tried with the abs() function..
What can be wrong?
The file is tested here: http://www.windsurfing.hu/proba2.asp

Thanks
Mate
Posted by takacsmatto
31st Oct 2009