Random Selection in Access

L

latwood

I have a list of over two hundred names and id#'s. I need to find a way to
randomly select about 30 names and/or id#'s from that list.

Any ideas?
 
A

Arvin Meyer [MVP]

latwood said:
I have a list of over two hundred names and id#'s. I need to find a way to
randomly select about 30 names and/or id#'s from that list.

Try this code and query:

Function GetRandomRecords() As Integer
Static intPicked As Integer
If intPicked = False Then Randomize
intPicked = True
GetRandomRecords = 0
End Function

Then run a query like:

Select Top 30 * From tblMyTable
Where GetRandomRecords() = 0
Order By Rnd(IsNull(RecordID) * 0 + 1)
 
Top