Randomly pick 5 records to print

G

Guest

I have a database written in Access 2003. I have a report that is based on a
query and a filter. The report may generate anywhere from 0 records to 1000+
records. I want the report to randomly pick only 5 of the records to actually
print. I want this to be a pure randomization of all of the records supplied
by the query and filter. And, of course, it should also be able to print all
records if there are 5 or less. Thank you.
 
G

Guest

Try this --
SELECT TOP X YourFieldNames, ...
Replace the "X" with the quanity of records you want.

If your table has an autonumber field then you can use a calculated field to
simulate a random number.
Right(Left((4.6345679/ [AutoNUM]) *10,000)5),3)
Sort it ascending.

For a different group use a different number than 4.6345679 in the formula.
 

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

Top