A
Andrew
I could use some help with the following issue. I have a form that needs to
generate a random sample. The criteria is that a sample of at least 10 but
no more than 50 needs to be selected (based on pulling 10% of the items to be
audited). 0 cannot be a returned since the recordset starts at 1. This is
selecting items to audit, so there should be no duplicates. Also, when the
result set comes back it would be extremely helpful if it would sort in
accending order. I am doing the best I can with this programming stuff, but
I am definately still learning. Any help would be greatly appreciated.
Below is the code we are currently using.
'generate the number of random numbers needed
iRandomNumberCount = Round((stNumberofDiscrepancies * 0.1), 0)
If Val(iRandomNumberCount) >= 10 And Val(iRandomNumberCount) <= 50
Then
iTotalCount = iRandomNumberCount
ElseIf Val(iRandomNumberCount) < 10 Then
iTotalCount = 10
ElseIf Val(iRandomNumberCount) > 50 Then
iTotalCount = 50
End If
'create the header
If lstRandomNumbers.ListCount = 0 Then
lstRandomNumbers.AddItem "ID Number"
End If
'generate the numbers needed to populate in table
Me.lstRandomNumbers.RowSource = ""
For iCounter = 1 To Val(iTotalCount)
'Generate random number
iRandomNumber = Int(stNumberofDiscrepancies * Rnd)
lstRandomNumbers.AddItem iRandomNumber
Next iCounter
End Sub
generate a random sample. The criteria is that a sample of at least 10 but
no more than 50 needs to be selected (based on pulling 10% of the items to be
audited). 0 cannot be a returned since the recordset starts at 1. This is
selecting items to audit, so there should be no duplicates. Also, when the
result set comes back it would be extremely helpful if it would sort in
accending order. I am doing the best I can with this programming stuff, but
I am definately still learning. Any help would be greatly appreciated.
Below is the code we are currently using.
'generate the number of random numbers needed
iRandomNumberCount = Round((stNumberofDiscrepancies * 0.1), 0)
If Val(iRandomNumberCount) >= 10 And Val(iRandomNumberCount) <= 50
Then
iTotalCount = iRandomNumberCount
ElseIf Val(iRandomNumberCount) < 10 Then
iTotalCount = 10
ElseIf Val(iRandomNumberCount) > 50 Then
iTotalCount = 50
End If
'create the header
If lstRandomNumbers.ListCount = 0 Then
lstRandomNumbers.AddItem "ID Number"
End If
'generate the numbers needed to populate in table
Me.lstRandomNumbers.RowSource = ""
For iCounter = 1 To Val(iTotalCount)
'Generate random number
iRandomNumber = Int(stNumberofDiscrepancies * Rnd)
lstRandomNumbers.AddItem iRandomNumber
Next iCounter
End Sub