Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

random rows

0 views
Skip to first unread message

Scott Reynolds

unread,
Sep 3, 2004, 6:45:05 AM9/3/04
to
Hello!

Is it possible to select random rows from the table.

Thank you in advance!
Scott


Nikos Yannacopoulos

unread,
Sep 3, 2004, 7:02:27 AM9/3/04
to
Scott,

You can do it with a little trick, using Access's built-in function Rnd(),
which returns random numbers between 0 and 1.
Make a query on the table, and add a calculated field in thequery grid, with
the expression:

RandomID: Rnd([SomeFieldName])

Change SomeFieldName in the expression above to the name of any other field
in your query; it doesn't matter which, this is only in order to force Rnd()
to return a new value in each record. Set the sorting to either Ascendig or
Descending on this calculated field, and set the query's Top Values property
to the desired number of records to be returned. The records rerturned will
be dirrerent each time.

HTH,
Nikos


"Scott Reynolds" <ad...@it-xenius.co.uk> wrote in message
news:Oo9kUMak...@TK2MSFTNGP09.phx.gbl...

0 new messages