I'm not sure about 2002, but the 2003 version offers Random as one of the
options for an autonumber. Another way would be the example below. It was
placed in the BeforeUpdate event of a form.
If Me.NewRecord Then
Randomize
'Make sure the number doesn't exist. If it does, try again.
Do
sglTestNumber = Rnd
Loop Until IsNull(DLookup("[Lottery Tie Breaker]", "tblBUMs", "[Lottery
Tie Breaker]=" & sglTestNumber))
Me.txtLotteryTieBreaker = sglTestNumber
End If
This will give a number >=0 and <1. If you want a different range of
numbers, that can be done also. The formula is:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
This will produce random integers between the upper and lower bound.
--
Wayne Morgan
MS Access MVP
lschordock said:
I'm trying to assign random numbers to a table in access for a
sweepstakes.
Anyone know how it can be done? Thanks!