How do I randomly divide data in Access?

A

Aaron Kempf

I'd reccomend just taknig a couple of copies of the database and then
sitting around and waiting

MDB randomly loses data-- so you would have a few databases with random
data-- if you just left it in MDB format
 
G

Graham Mandeno

Hi Janice

[Sorry about AK - you get all types in a public forum!!]

If your table includes a field that is guaranteed to have a positive number
in it (for example an AutoNumber field) then you can create a query on the
table with a calculated field such as this:

RandomOrder: Rnd([FieldName])

This field will have a random number >=0 and <1.

You can then sort your query on that field and thus return the records in a
random order, or use a TOP N query to select N random records from the
table.

You can also assign records to random groups like this:

RandomGroup: Int(Rnd([FieldName]) * 6)

This will generate one of 6 random integers from 0 to 5 inclusive, which you
can use to group or divide the records.
 
A

Aaron Kempf

I speak the truth, kid


Graham Mandeno said:
Hi Janice

[Sorry about AK - you get all types in a public forum!!]

If your table includes a field that is guaranteed to have a positive number
in it (for example an AutoNumber field) then you can create a query on the
table with a calculated field such as this:

RandomOrder: Rnd([FieldName])

This field will have a random number >=0 and <1.

You can then sort your query on that field and thus return the records in a
random order, or use a TOP N query to select N random records from the
table.

You can also assign records to random groups like this:

RandomGroup: Int(Rnd([FieldName]) * 6)

This will generate one of 6 random integers from 0 to 5 inclusive, which you
can use to group or divide the records.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


Janice said:
In Access 2003 I need to randomly divide the data in a table.
 
Top