random number generator

A

aspgk

Hello:

i want to set a value.. call it delay time... using an access function that
would statistically select a number with a range... say 1-100. Is this
possible in Access? I sure can't find it if there is one...

Please advise & thanks

Paul
 
R

raskew via AccessMonster.com

Hi -

Copy/paste this to a standard module

Public Function GenRndNumber(Upper As Double, Lower As Double) As Double
Randomize
GenRndNumber = Int((Upper - Lower + 1) * Rnd + Lower)
End Function

...then call it (from the debug (immediate) window like this:

? GenRndNumber(100, 1)

HTH - Bob
 
G

Golfinray

Access will generate random number with the RND command. You could do
rnd([>100]), rnd([<1]), rnd([>.000001]), etc to get whatever range you need.
If you leave it blank, you will just get some random number.
 
M

Marshall Barton

aspgk said:
i want to set a value.. call it delay time... using an access function that
would statistically select a number with a range... say 1-100. Is this
possible in Access? I sure can't find it if there is one...


Look in VBA Help for the Rnd function and the Randomize
statement.
 
A

aspgk

thanks for taking the time to respond to this

Golfinray said:
Access will generate random number with the RND command. You could do
rnd([>100]), rnd([<1]), rnd([>.000001]), etc to get whatever range you need.
If you leave it blank, you will just get some random number.

aspgk said:
Hello:

i want to set a value.. call it delay time... using an access function that
would statistically select a number with a range... say 1-100. Is this
possible in Access? I sure can't find it if there is one...

Please advise & thanks

Paul
 
A

aspgk

thank you .....

raskew via AccessMonster.com said:
Hi -

Copy/paste this to a standard module

Public Function GenRndNumber(Upper As Double, Lower As Double) As Double
Randomize
GenRndNumber = Int((Upper - Lower + 1) * Rnd + Lower)
End Function

...then call it (from the debug (immediate) window like this:

? GenRndNumber(100, 1)

HTH - Bob
 
J

John W. Vinson/MVP

Access will generate random number with the RND command. You could do
rnd([>100]), rnd([<1]), rnd([>.000001]), etc to get whatever range you need.
If you leave it blank, you will just get some random number.

Golfinray, won't the square brackets have Access looking for a Field
or a Parameter named [>100] or the like? Take a look at the online
help for Rnd - it doesn't work the way you're describing!
 
Top