bd528
bd528

Reputation: 886

Random number script producing non-random number in Access VBA

I am using the code below to generate a random number :-

Dim LRandomNumber   As Integer

LRandomNumber = Int((999 - 100 + 1) * Rnd + 100)

The code was taken from https://www.techonthenet.com/access/functions/numeric/rnd.php

However every time I run the code in MS Access, LRandomNumber = 734.

Am I using the code incorrectly, and if not, is the a better way to generate a random number between 1 and 1000?

Upvotes: 0

Views: 82

Answers (1)

braX
braX

Reputation: 11755

Call Randomize on the line before it.

Upvotes: 2

Related Questions