Random record

  • Thread starter Thread starter Genius Maximus
  • Start date Start date
G

Genius Maximus

I have a table with records
I want the query to select me a random record from this table.
Each time the query runs, it should be a different record...

Is it possible in a Query?
Or do I need Visual Basic code for this.

Thanks
 
Genius said:
I have a table with records
I want the query to select me a random record from this table.
Each time the query runs, it should be a different record...

Is it possible in a Query?
Or do I need Visual Basic code for this.


Well you should use the Randomize statement somewhere in
code before running the query:

SELECT TOP 1 *
FROM table
ORDER BY Rnd([keyfield])

Might not be very efficient is a large table, but at least
it shows it's possible.
 
Back
Top