SQL is optimizing your query and is calling Rnd only once. You need to trick it into making the call for each record retrieved. First write a function
Code:
Public Function MyRnd(x As Variant) As Long
MyRnd = (500000 - 50000) * Rnd + 50000
End Function
Then write your SQL as
Code:
SELECT myTable.myField, MyRnd(myTable.myField) AS RandomNumber
FROM myTable;
Where you pass any field from your record into the function. It doesn't really matter which one because (as you can see) the value isn't used in the function. It's purpose is to force SQL to evaluate the function for every record.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.