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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The code gets to the end of the dataset.Rows.Count

Status
Not open for further replies.

dollarbillg

Programmer
Dec 3, 2002
12
0
0
US
At the end of the second loop the Catch says that there are no rows at position 15. There are only 14 rows in that table and I am aware of that. What I attended on happening was that it would loop thru the rows and when the condition wasn't met to display the CodeItem2 form.
************************************************************Here's the code:

If Me.ConfigurationList1.T2_WORKING_AUX.Rows.Count > 0 Then
'show the CodeItem form if the RIN has been coded
'for assessment
Try
Dim x As Integer
Dim i As Integer
Do Until x = Me.ConfigurationList1.T2_WORKING_AUX.Rows.Count
x += 1
If Me.ConfigurationList1.T2_WORKING_AUX.Item(x).CONFIG_ID = CType(Me.xConfigID.Text.ToString, Integer) Then

ShowLookupForm(AddAProblem)

End If
Loop
Do Until i = Me.ConfigurationList1.T2_WORKING_AUX.Rows.Count
i += 1
If Me.ConfigurationList1.T2_WORKING_AUX.Item(x).CONFIG_ID <> CType(Me.xConfigID.Text.ToString, Integer) Then

ShowLookupForm(CodeItem2)

Else

End If

Loop

Catch ex As Exception

MessageBox.Show(ex.ToString)

End Try


End IF

***********************************************************
Thanks dollarbillg
 
The Row.Count property returns the number of rows, but when you are referrencing the row you have to remember it's zero based. Could that be your problem, that you are starting your integer count with 1 instead of 0?

And you might try :
Do Until x = Me.ConfigurationList1.T2_WORKING_AUX.Rows.Count - 1


 
It is because you are incrementing your counter variable (i) before you perform the validation.

Do it as the last statement inside your loop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top