By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

configure field as random between 2 numbers?

P: n/a
MN
I know that there is a way to define an autonumber field as random but
is there anyway to configure a random field to only produce a number
within a certain range, for example between 55 and 88?

Thanks.
Aug 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Public Function GetRandomNo() As Integer
GetRandomNo = Int((55 * Rnd) + 33)
End Function

Aug 23 '06 #2

P: n/a
MN wrote:
I know that there is a way to define an autonumber field as random but
is there anyway to configure a random field to only produce a number
within a certain range, for example between 55 and 88?

Thanks.
>From A97 Help file for Rnd Function:
The Rnd function returns a value less than 1 but greater than or equal
to zero.

A to B (inclusive)

Int(((B - A + 1) * Rnd) + A)

E.g.,

55 to 88 (inclusive)

Int((34 * Rnd) + 55)

Note that the example given in the Help file using A = 1 and B = 6 is
somewhat misleading because of the choice of A.

James A. Fortune
CD********@FortuneJames.com

Aug 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.