Randomize records of names

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

My table has 1000+ records of names. There is a field for last name. The last
names are in alphabetical order. How can I reorder the names either in the same
table or in a new table where the last names are in random order? This is just
data for now so I'm not concerned about losing the primary key values.

Thanks!

Tom
 
Tom said:
My table has 1000+ records of names. There is a field for last name. The last
names are in alphabetical order. How can I reorder the names either in the same
table or in a new table where the last names are in random order? This is just
data for now so I'm not concerned about losing the primary key values.

I don't see why you would need another table for this.

Actually, a table is not in any particular order, it is an
unordered "bucket" of records. If you want the table's
records presented in some order, you **must** use a query
with an ORDER BY clause to specify the order. For your
question, just use a query to select the names in a random
order:

SELECT LastName FROM table ORDER BY Rnd([keyfield])

where keyfield is any numeric field in the table with
positive values (an AutoNumber field is good for this). The
only issue with this approach is that you may need to pay
attention to how you start the randomizing sequence by
executing the Randomize statement.
 
Back
Top