Run-time error 3021 "Either BOF or EOF is true, or the current record has been deleted.

crystalsoft
crystalsoft used Ask the Experts™
on

i am trying to move records from one database table to another database table ( But same structure in both table )

code is attached

''''''''''Connection For Mover.MDB file for transfering data from Trant.MDb to Mover.MDB
    If RecvKKL_Cnn.State = 1 Then RecvKKL_Cnn.Close
        RecvKKL_Cnn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & "\Mover.mdb;Jet OLEDB:Database Password=xxxxxxxx"


    If RecvLCL.State = 1 Then RecvLCL.Close
        RecvLCL.Open "select * from B_Detail WHERE LsNo = " & Text1(18).text & " and Check = 1", con, adOpenKeyset, adLockOptimistic
        
    If RecvKKL.State = 1 Then RecvKKL.Close
        RecvKKL.Open "Select * from B_Detail", RecvKKL_Cnn, adOpenKeyset, adLockOptimistic
        
        If RecvLCL.RecordCount > 0 Then
        
            While Not RecvLCL.EOF
                
                RecvKKL!bno = RecvLCL!bno
                RecvKKL!Mode = RecvLCL!Mode
                RecvKKL!bdate = RecvLCL!bdate
                
                RecvLCL.MoveNext
            Wend
        End If

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
Where are you getting the error?

Author

Commented:

                RecvKKL!bno = RecvLCL!bno

Author

Commented:

is any other way to copy records from one database table to another database table  ???

Retired
Top Expert 2012
Commented:
I think you need to add a new record each time, and then update it before adding the next one.
''''''''''Connection For Mover.MDB file for transfering data from Trant.MDb to Mover.MDB
    If RecvKKL_Cnn.State = 1 Then RecvKKL_Cnn.Close
        RecvKKL_Cnn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & "\Mover.mdb;Jet OLEDB:Database Password=xxxxxxxx"


    If RecvLCL.State = 1 Then RecvLCL.Close
        RecvLCL.Open "select * from B_Detail WHERE LsNo = " & Text1(18).Text & " and Check = 1", con, adOpenKeyset, adLockOptimistic
        
    If RecvKKL.State = 1 Then RecvKKL.Close
        RecvKKL.Open "Select * from B_Detail", RecvKKL_Cnn, adOpenKeyset, adLockOptimistic
        
        If RecvLCL.RecordCount > 0 Then
        
            While Not RecvLCL.EOF
                RecvKKL.AddNew '<---------
                RecvKKL!bno = RecvLCL!bno
                RecvKKL!Mode = RecvLCL!Mode
                RecvKKL!bdate = RecvLCL!bdate
                RecvKKL.Update '<----------
                RecvLCL.MoveNext
            Wend

Open in new window

Author

Commented:
GrahamSkan:

Such a Genius :-D

Thanks and thanks and thanks a lot

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial