Randomize Macro

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

Guest

Hi,

We have a database which is constantly changing and as a result whenever we
train staff we are constantly updating the training database as well.

What we'd like to do is just take a copy of the database and run a macro
which will randomize the staff names. We dont go in depth on personal
details in training so this would be fine for us.

Is it possible to create a macro that will randomize the existing names in
the staff table?

Many thanks

Ian
 
Take a look at the DFirst/DLast functions. Sounds like this may do just what
you're needing.
 
Ian,

Can you give some examples of what this would look like, I'm afraid I
haven't grasped the concept here.
 
For example the database may have staff such as

John Smith
David Williams
William Thomas etc

We're not supposed to use real information for training purposes but it
would be fine if we could somehow randomize the names. Then we would not
know hows records we are refering to. So after randomizing the name fields
which are Forename and Surname by the way we might have:

John Thomas
David Smith
William Williams etc
 
Ian,

Thanks for the further explanation... I would never in a million years
have guessed that that's what you wanted. :-)

Well, at the moment I can't think of a way to do this using queries or
macros. However, I think it could be done in a VBA procedure, by
looping through 2 recordsets both based on the same table but sorted in
a different way, and updating one with the other. It might look a bit
like this (caution: air code!)...

Dim rstBase as DAO.Recordset
Dim rstSort as DAO.Recordset
Dim dbs As Database
Set dbs = CurrentDb
Set rstBase = dbs.OpenRecordset("SELECT ForeName FROM Staff ORDER BY
Surname")
Set rstSort = dbs.OpenRecordset("SELECT ForeName FROM Staff ORDER BY
Mid([Forename],2)")
With rstBase
Do Until .EOF
.Edit
!ForeName = rstSort!ForeName
.Update
.MoveNext
rstSort.MoveNext
Loop
End With
Set rstSort = Nothing
Set rstBase = Nothing
 
Back
Top