MajP
You've got your good things, and you've got mine.
- Local time
- Today, 14:06
- Joined
- May 21, 2018
- Messages
- 9,025
I have the following procedure to assign random order to records and it works.
The first time I Run the method I get this order
A
I
T
B
L
E
Y
E
?
P
Second time I run it I get this order
E
E
U
N
O
E
R
F
I
N
Now if I close the DB and reopen it and run the method
1st Time
Letter
A
I
T
B
L
E
Y
E
?
P
Second Time
Letter
E
E
U
N
O
E
R
F
I
N
This is exactly what I would expect if I did not Include Randomize. I would get a random patterns each time, but every time I open the db I would get the same order of random patterns. However I included Randomize. I would expect different random patterns.
Any Idea or this some kind of bug?
Code:
Public Sub ShuffleTileOrder()
'Update the table at beginning of game
Dim i As Integer
Dim rs As DAO.Recordset
Dim strSql As String
Randomize (CDbl(Now))
strSql = "Select rnd([Letterid]) as sort, letter, Letterorder from tblGameLetters order by rnd([Letterid])"
Set rs = CurrentDb.OpenRecordset(strSql)
Do While Not rs.EOF
i = i + 1
rs.Edit
rs!Letterorder = i
rs.Update
rs.MoveNext
Loop
End Sub
The first time I Run the method I get this order
A
I
T
B
L
E
Y
E
?
P
Second time I run it I get this order
E
E
U
N
O
E
R
F
I
N
Now if I close the DB and reopen it and run the method
1st Time
Letter
A
I
T
B
L
E
Y
E
?
P
Second Time
Letter
E
E
U
N
O
E
R
F
I
N
This is exactly what I would expect if I did not Include Randomize. I would get a random patterns each time, but every time I open the db I would get the same order of random patterns. However I included Randomize. I would expect different random patterns.
Any Idea or this some kind of bug?