Randomize records of names

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
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top