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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top