Amatts,
I can not post to the original thread. I get a cold fusion error. So here is the answer to the Thread "Input To Seed a Random Picker"
I am a little confused on the thread because I wrote the original code cited. The whole purpose of the code was to avoid getting the same random sequence everytime you enter the database. The code was written to avoid the default behavior, which appears to be what you want. So instead of using myRandom you can just use Rnd.
Did you read the original thread? The whole issue was every time they opened the database they got the same pseudo list of cleaners selected.
If you use the Rnd function with a given seed pull the list, close the database, reopen the database, and pull the list again with the same seed you will get the same random list. So not sure what the issue here is.
You can also use this code
You then do not have to close the database to return a previous random list. You just have to reset the seed prior to calling the list.
You also have to be careful. Any subsequent calls to the function (such as a requery) without resetting the seeds will give another sequence.
I can not post to the original thread. I get a cold fusion error. So here is the answer to the Thread "Input To Seed a Random Picker"
I am a little confused on the thread because I wrote the original code cited. The whole purpose of the code was to avoid getting the same random sequence everytime you enter the database. The code was written to avoid the default behavior, which appears to be what you want. So instead of using myRandom you can just use Rnd.
Did you read the original thread? The whole issue was every time they opened the database they got the same pseudo list of cleaners selected.
If you use the Rnd function with a given seed pull the list, close the database, reopen the database, and pull the list again with the same seed you will get the same random list. So not sure what the issue here is.
You can also use this code
Code:
Option Explicit
Public ix As Integer
Public iy As Integer
Public iz As Integer
Public blnSeedSet As Boolean
Public Sub SetSeedRepeatable(SeedOne As Integer, SeedTwo As Integer, SeedThree As Integer)
' IX, IY and IZ should be set to integer values between 1 and
' 30000 before the first entry.
ix = SeedOne
iy = SeedTwo
iz = SeedThree
blnSeedSet = True
End Sub
Public Function RepeatableRnd(Force As Variant) As Double
Dim dx As Double
Dim dy As Double
Dim dz As Double
Dim top As Double
Dim tmp As Long
Dim c1 As Double
Dim c2 As Double
Dim c3 As Double
Dim l1 As Long
Dim l2 As Long
Dim l3 As Long
Dim r1 As Long
Dim r2 As Long
Dim r3 As Long
If Not blnSeedSet Then
MsgBox "Seed Not Set"
Exit Function
End If
l1 = 171
l2 = 172
l3 = 170
r1 = 30269
r2 = 30307
r3 = 30323
c1 = CDbl(r1)
c2 = CDbl(r2)
c3 = CDbl(r3)
ix = (l1 * ix) Mod r1
iy = (l2 * iy) Mod r2
iz = (l3 * iz) Mod r3
dx = CDbl(ix)
dy = CDbl(iy)
dz = CDbl(iz)
' Generate random uniform number
top = ((dx / c1) + (dy / c2) + (dz / c3))
tmp = Int(top)
RepeatableRnd = top - tmp
End Function
You then do not have to close the database to return a previous random list. You just have to reset the seed prior to calling the list.
You also have to be careful. Any subsequent calls to the function (such as a requery) without resetting the seeds will give another sequence.