Getting run time error 3021 either BOF or EOF is true, or current record has been deleted, Requested opration...

Getting run time error 3021
either BOF or EOF is true, or current record has been deleted, Requested opration....

    If RsRecList.RecordCount > 0 Then   '5 records

        ''i want to filter above above 5 records and getting desired data 
            With RsRecList
                Do While RsRecList.EOF
                    If RsCmHama.State = 1 Then RsCmHama.Close
                    RsCmHama.Open "Select * from CmMaster where Cust = '" & Text1(11).Text & "' and From_City = '" & DataGrid2.Columns(7).Text & "' and To_City = '" & DataGrid2.Columns(8).Text & "'", con, adOpenKeyset, adLockOptimistic
                    If RsCmHama.RecordCount > 0 Then
                        If RsCmHama.Fields(4) = "CASH" Then
                            CmHamaWeight = Val(CmHamaWeight) + Val(DataGrid2.Columns(11).Text) * RsCmHama.Fields(5)
                        ElseIf RsCmHama.Fields(4) = "CREDIT" Then
                            CmHamaArt = Val(CmHamaArt) + Val(DataGrid2.Columns(3).Text) * RsCmHama.Fields(5)
                        End If
                    End If
            End With
    End If

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

    Do While RsRecList.EOF
    Do Until m_oRsTemp.EOF
And add this below the line "RsCmHama.Open ..." :
    If Not RsCmHama Is Nothing Then
        If RsCmHama.State = adStateOpen Then
crystal_TechAuthor Commented:
Thanks for reply

Its not going for another record..
form this line
                Do Until RsRecList.EOF
its not going for next record..
below the line:
    If RsRecList.RecordCount > 0 Then   '5 records
If RsRecList is the underlying recordset of DataGrid2 then use it's fields instead of DataGrid2.Columns(n).Text

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crystal_TechAuthor Commented:
its working. :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.