[thelist] Select random records from an Access database

Anthony Baratta anthony at baratta.com
Fri Mar 19 14:00:27 CST 2004

At 11:44 AM 3/19/2004, Marco Orlandi wrote:
>Hi all........
>               I need to select 8 random records among the last 100 in an 
> Access database, containing an undefined number of records.
>               8 and 100 are example values: actually the user should be 
> able to choose both numbers ( using a form......... ), but the most 
> difficult job to me is to built the select code, via a VBScript ASP page.......

What you can do is build a temp table with an identity (autonumber) column. 
In the temp table you just have the id of the rows from the table you want 
to "randomly" pick from. Then the user or your program picks 1 thru 100, 
the program links the two tables together and you get your rows. When you 
are done, drop the temp table.

Anthony Baratta
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."

More information about the thelist mailing list