The secret is the use of RANDOMIZE.
Here is an example
Code:
'---------------------------------------------------------------------------------------
' Procedure : randomNumber
' Author : Jack
' Created : 11/18/2010
' Purpose : To Generate Random numbers between and including a range of numbers.
'Lo and Hi are the lowest and highest random numbers you wish to generate.
'
'The Randomize keyword is critical to getting different results for each Access session.
'=======================================================================================
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: N/A
'------------------------------------------------------------------------------
'
Function randomNumber(Lo As Long, Hi As Long) As Long
10 On Error GoTo randomNumber_Error
30 Randomize
40 randomNumber = Int((Hi - Lo + 1) * Rnd + Lo)
50 On Error GoTo 0
60 Exit Function
randomNumber_Error:
70 MsgBox "Error " & err.number & " in line " & Erl & " (" & err.Description & ") in procedure randomNumber of Module AccessM"
End Function