Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi
I have written this code in Visual Basic 6 . It is giving me error "Runtime error 3021 either eof or bof is true or the current record has been deleted"

VB
Dim m_section As String
        If rs.RecordCount > 0 Then
             Do While Not rs.EOF
             If rs.EOF Then Exit Do
                rowcount = 1
                m_section = ""
                m_section = rs.Fields("section_id").Value
'                If m_section = "S03" Then Exit Do
                flxgd.Cols = flxgd.Cols + 1
                flxgd.ColWidth(flxgd.Cols - 1) = 2000
                flxgd.TextMatrix(0, flxgd.Cols - 1) = m_section

                    Do While (rs.Fields("section_id").Value) = m_section
                        If (flxgd.Cols - 1) = 1 Then
                            flxgd.TextMatrix(rowcount, 0) = DateValue(rs!s_date)
                        End If
                        flxgd.TextMatrix(rowcount, flxgd.Cols - 1) = rs.Fields("quantity").Value
                        rs.MoveNext
                        flxgd.Rows = flxgd.Rows + 1
                        flxgd.Row = flxgd.Row + 1
                        rowcount = rowcount + 1
                    Loop

                m_grdwidth = m_grdwidth + 2000
            Loop
        End If



Thanks
Posted
Updated 28-Nov-12 15:44pm
v2

1 solution

VB
'Make sure your table is not empty
If RS.RecordCount = 0 Then Exit Sub
'Make sure the Absolute Position of the record's cursor is at the right position, If not then Exit Sub
'If the Absolute Position reached the last record then Exit Sub.
If RS.AbsolutePosition = Val(RS.RecordCount) Then 
Exit Sub
End If
'Navigate [MoveNext]
RS_.MoveNext
Text1.Text = RS!FieldName1
Text2.Text = RS!FieldName2

[Visit me]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900