Select the product you need help with
How to find N records in random order in Access 2002Article ID: 287682 - View products that this article applies to. This article was previously published under Q287682 Novice: Requires knowledge of the user interface on single-user computers.
For a Microsoft Access 97 version of this article, see 128874 For a Microsoft Access 2000 version of this article, see 208855
(http://support.microsoft.com/kb/128874/
)
.
(http://support.microsoft.com/kb/208855/EN-US/
)
.
SUMMARY
This article shows you how to shuffle the records in a table in random
order. It also shows you how to get <n> records from a table at random (where <n> is the number of records that you want). You can use this method to make sure that the records will never be repeated.
MORE INFORMATION
To shuffle the records in a table, create a query that is based on that table and all its necessary fields. Add a calculated field that contains the Rnd() function with a positive integer variable parameter. Then, sort by this calculated field. Every time that you evaluate the query, the records will be shuffled.
To get <n> records at random, set the TopValues property of the query to the number of records that you want. The Rnd() function requires a numeric argument to return a random number. If the argument is greater than zero, the next random number in the sequence is returned. Because of the way queries are optimized, if you create a calculated field with a numeric argument such as REFERENCESFor more information about the TopValues property, click Microsoft Access Help on the Help menu, type topvalues in the Office Assistant or the Answer Wizard, and then click Search to view the topic. PropertiesArticle ID: 287682 - Last Review: August 11, 2004 - Revision: 1.0
| Article Translations |


Back to the top








