Hello All,
Is it possible to create multiple random numbers in a query where
there are numerous records?
I've created a custom function. When I use it in a query it creates
the same random number for ALL the records. It appears the function is
only getting called once, therefore only one random number is being
generated for all the records. I want a different random number for
each record. Is this possible, or do I have to do it all in code and
add the random number as data to a field in the table?
What I did is below. At least the short version:
Query:
SELECT tblInvCurYr.ID, ReturnRndCGSPer c(1) AS InvCGSPerc FROM
tblInvCurYr;
Random Function in Code:
Function ReturnRndCGSPer c(dblCGSperc As Double)
Randomize 'initialize random number generator
dblCGSperc = (0.8 - 0.6) * Rnd + 0.6
ReturnRndCGSPer c = dblCGSperc
End Function
TIA!
--
Regards,
Greg Strong