Random Generator

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone tell me how to create a random generator that will pull from a
table and display specified fields in a form?
 
I had this code squirreled away; I don't usually hold hacks unless I've
tested them, so I think it's viaable.

This SQL will return 10 random records

SELECT TOP 10 Rnd(Len([PrimaryKeyField])) AS Expr1,YourTable.PrimaryKeyField,
YourTable.Field1,YourTable.Field2,YourTable.Field3
FROMYourTable
ORDER BY Rnd(Len([PrimaryKeyField])) DESC;

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
In
missinglinq via AccessMonster.com said:
I had this code squirreled away; I don't usually hold hacks unless
I've tested them, so I think it's viaable.

This SQL will return 10 random records

SELECT TOP 10 Rnd(Len([PrimaryKeyField])) AS
Expr1,YourTable.PrimaryKeyField,
YourTable.Field1,YourTable.Field2,YourTable.Field3
FROMYourTable
ORDER BY Rnd(Len([PrimaryKeyField])) DESC;

You must arrange to execute the Randomize statement at some point before
calling the Rnd() function, if you want the result to reasonably random.
 
Back
Top