Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to select a given number of random records in a query. 1

Status
Not open for further replies.

stotzc001

Technical User
Mar 27, 2003
30
US
I have a database that is used for testing purposes. What I want to do is create a select query that would pick 100 questions at random from a table of about 400 records. However, I have been unable to find any function withing Access for selecting random records. Any Ideas?

 
Create a Public Funtion:

Public Function RndRecords(sngNuma As Single) As Single
Randomize
RndRecords = Rnd
End Function

Save it with the name basRandom

In a Make table query add the fields you want in the new table and RndRecords([Name of your Pimary Key]) in the Top Values combobox from the toolbar enter 100. Run the make table query and enjoy the results

HTH
"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top