OP has not demonstrated that the problem is with the random number.
In fact, the code producing the Result variable in Post#1 is valid (see below), so the problem is either elsewhere in the code or due to bad data.
Edit: In original post#1, it appears that Option Explicit has not been specified, as there is no visible declaration for n, nor has rs been declared as a DAO.recordset, or sql as string.
Code:
Public Sub Check()
Dim n As Integer, Result As Integer, Count As Long, j As Integer
Dim lowresult As Integer: lowresult = 1
Dim highResult As Integer: highResult = 20
Dim agg As Long
Randomize
For n = 0 To 21
For j = 1 To 1000
Result = lowresult + Int((highResult - lowresult + 1) * Rnd())
If Result = n Then Count = Count + 1
If Result < 1 Or Result > 20 Then Debug.Print "???? " & Result
DoEvents
Next j
Debug.Print n, Count
agg = agg + Count
Count = 0
Next n
Debug.Print agg
End Sub
This code generates the random number 22000 times, 1000 times each for the numbers 0 thru 21 and counts the total occurrences that each (0-21) happens for the 1000 generations.
The random number generated is never less than one or greater than twenty.
The perfect count is 50, and you can see below that the count falls within an acceptable random nominal range. Each time the test is run, the counts are different, clustering around 50 (random!).
Immediate window:
check
0 0
1 53
2 59
3 45
4 53
5 63
6 62
7 62
8 60
9 44
10 46
11 43
12 47
13 49
14 51
15 61
16 55
17 43
18 50
19 46
20 46
21 0
1038