Generating Random Numbers

  • Thread starter Thread starter Joe Williams
  • Start date Start date
J

Joe Williams

I have a form that has a text box that I would like to generate a random
number every time it is opened. Each client that gets a copy of the front
end should get in most cases a different number in the text box.

My problem is that 8 times out of ten, the text box gives each front end the
same random number. Is there something I am doing wrong in generating the
random number or is there another way to approach this? here is the code for
the text box that is generating the random number:

in the form load event: Me.value = Int(100 * Rnd) + 1

Most of the time it returns 71. What I need is it to REALLY be random and
rarely return the same number.

Thanks

joe
 
Joe said:
I have a form that has a text box that I would like to generate a random
number every time it is opened. Each client that gets a copy of the front
end should get in most cases a different number in the text box.

My problem is that 8 times out of ten, the text box gives each front end the
same random number. Is there something I am doing wrong in generating the
random number or is there another way to approach this? here is the code for
the text box that is generating the random number:

in the form load event: Me.value = Int(100 * Rnd) + 1

Most of the time it returns 71. What I need is it to REALLY be random and
rarely return the same number.


Computers can't do true random numbers, but you can probably
get a lot closer by using the Randomize statement.
 
Joe said:
I have a form that has a text box that I would like to generate a
random number every time it is opened. Each client that gets a copy
of the front end should get in most cases a different number in the
text box.
My problem is that 8 times out of ten, the text box gives each front
end the same random number. Is there something I am doing wrong in
generating the random number or is there another way to approach
this? here is the code for the text box that is generating the random
number:
in the form load event: Me.value = Int(100 * Rnd) + 1

Most of the time it returns 71. What I need is it to REALLY be random
and rarely return the same number.

You could set up an autonumber field and set it to random, then use just the
last n digits.
 
Back
Top