I am going to use the following code to work my way through 32,000 records in a table and use a random number generator to select records randomly from varying-sized subsets of the 32,000 records. I know that the function will run much faster and be easier to write if the records are sorted the way I want them sorted (which would place together those subsets I mentioned), as opposed to the way they were originally imported from a text file (which would mean I would have to go through all 32,000 records for each of 160 subsets of records). I have tried sorting them and saving the changes, but when I run the code, it's still the ORIGINAL 20th record that gets modified.
I know I could probably create 160 smaller tables for the subsets of records, but I would rather avoid that.
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
strSQL = "SELECT UniverseTemp.Sampled FROM UniverseTemp;"
Set rs = db.OpenRecordset(strSQL)
For x = 1 To 20
If x = 20 Then
rs.edit
rs!Sampled = True
rs.Update
End If
rs.MoveNext
Next x
I know I could probably create 160 smaller tables for the subsets of records, but I would rather avoid that.