configure field as random between 2 numbers?

  • Thread starter Thread starter MN
  • Start date Start date
M

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.
 
Public Function GetRandomNo() As Integer
GetRandomNo = Int((55 * Rnd) + 33)
End Function
 
MN said:
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
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top