Hi,
Can anyone offer an explanation please? (Code below).
I have a program that reads through a dataset looking at items 7 and 8.
If item 7 has a particular value ("R") then I wish to delete the record.
A filter 'srsshow' is turned on to activate the feature.
When the filter is activated, this always returns an error - 'There is no row at position 9'.
However if the line with the remove statement is disabled, the loop runs right through the file without a problem, indicating that this is the line that is causing trouble. Also, the last 'debug.writelin e ' before the error message returns "line 8".
What is the problem?
Why does the 'debug.writelin e' not show "9" as it is executed before the line causing the error?
Many thanks.
Phil
For x = 0 To mdrows - 1
For y = 7 To 8
dataread = dt.Rows(x).Item (y)
'discard records not required
If y = 7 And srshow = 0 And dataread = "R" Then skiprec = 1
Next y
Debug.WriteLine ("line " & x )
If skiprec = 1 Then dt.Rows.Remove( dt.Rows(x))
skiprec = 0
y = 7
Next x
Can anyone offer an explanation please? (Code below).
I have a program that reads through a dataset looking at items 7 and 8.
If item 7 has a particular value ("R") then I wish to delete the record.
A filter 'srsshow' is turned on to activate the feature.
When the filter is activated, this always returns an error - 'There is no row at position 9'.
However if the line with the remove statement is disabled, the loop runs right through the file without a problem, indicating that this is the line that is causing trouble. Also, the last 'debug.writelin e ' before the error message returns "line 8".
What is the problem?
Why does the 'debug.writelin e' not show "9" as it is executed before the line causing the error?
Many thanks.
Phil
For x = 0 To mdrows - 1
For y = 7 To 8
dataread = dt.Rows(x).Item (y)
'discard records not required
If y = 7 And srshow = 0 And dataread = "R" Then skiprec = 1
Next y
Debug.WriteLine ("line " & x )
If skiprec = 1 Then dt.Rows.Remove( dt.Rows(x))
skiprec = 0
y = 7
Next x
Comment