Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHAT'S WRONG WITH THIS LOOP !!!!?????

Status
Not open for further replies.

teknophile

Programmer
Mar 29, 2001
3
GB
Private Sub Command1_Click()
Dim i, a, x As Integer
Dim array1(1 To 49) As Integer
rsControls.MoveFirst

For x = 1 To 49
array1(x) = array1(x) + 1
Next
Do While Not rsControls.EOF
rsControls.MoveFirst
For a = 1 To 49
For i = 1 To 49
******* If rsControls.Fields(&quot;No1&quot;) = i Then <Here I get an error. record is not there or something. The database is ok and the record is there.
******
array1(i) = array1(i) + 1
ElseIf rsControls.Fields(&quot;No2&quot;) = i Then
array1(a) = array1(a) + 1
ElseIf rsControls.Fields(&quot;No3&quot;) = i Then
array1(a) = array1(a) + 1
ElseIf rsControls.Fields(&quot;No4&quot;) = i Then
array1(a) = array1(a) + 1
ElseIf rsControls.Fields(&quot;No5&quot;) = i Then
array1(a) = array1(a) + 1
ElseIf rsControls.Fields(&quot;No6&quot;) = i Then
array1(a) = array1(a) + 1
ElseIf rsControls.Fields(&quot;Bonus&quot;) = i Then
array1(a) = array1(a) + 1
Else
rsControls.MoveNext
End If
Next i
Next a
Loop

i = 1
For i = 1 To 49
List1.AddItem (array1(i))
Next i
End Sub
 
WARNING: The following statement defines i and a as Variants, the default, not integers
Dim i, a, x As Integer
either use
Dim i as integer, a as integer, x as integer
OR
Dim i as integer
Dim a as integer
Dim x as integer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top