Write a function that randomly returns one of your six values.
Function RandVal(Dummy As Long) As Integer
RandVal = Int((6 * Rnd) + 1)
End Function
Then write a update query that call the function.
UPDATE tblSomeTable SET RandColumn = RandVal([PrimaryKey])
Note that we are passing a dummy value to the to the RandVal function. If
your table has an autonumber primary key you can use this value. If you do
not pass this dummy value then the query optimizer will only call the
function once, and use the same value to update ALL of the rows. When
passing the dummy value the optimizer is forced to call the function for
each row.
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.