Run-time error 3021. No current record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hpesoj
    New Member
    • Nov 2010
    • 3

    Run-time error 3021. No current record

    When i copy data form to multiple form i get a "Run-time error 3021. No current record " in the line "rst2.MoveLast" ...Can you help me out...

    Code:
    Private Sub Process_AfterUpdate()
    Dim db As DAO.Database
    Dim rst11 As DAO.Recordset
    Dim rst10 As DAO.Recordset
    Dim rst9 As DAO.Recordset
    Dim rst8 As DAO.Recordset
    Dim rst7 As DAO.Recordset
    Dim rst6 As DAO.Recordset
    Dim rst5 As DAO.Recordset
    Dim rst4 As DAO.Recordset
    Dim rst3 As DAO.Recordset
    Dim rst2 As DAO.Recordset
    Dim rst1 As DAO.Recordset
    
    Set rst11 = Forms!frm_BIA!frm_jobtraing.Form.RecordsetClone
    Set rst10 = Forms!frm_BIA!frm_Vtlrcrd.Form.RecordsetClone
    Set rst9 = Forms!frm_BIA!frm_off_telrequ.Form.RecordsetClone
    Set rst8 = Forms!frm_BIA!frm_othrasset.Form.RecordsetClone
    Set rst7 = Forms!frm_BIA!frm_sffreq.Form.RecordsetClone
    Set rst6 = Forms!frm_BIA!frm_essintrcntrct_con.Form.RecordsetClone
    Set rst5 = Forms!frm_BIA!frm_mnulprcdre.Form.RecordsetClone
    Set rst4 = Forms!frm_BIA!frm_resorcsrequrmnt.Form.RecordsetClone
    Set rst3 = Forms!frm_BIA!frm_endtoendprcs.Form.RecordsetClone
    Set rst2 = Forms!frm_BIA!frm_prcscrticl_crtria_crtocatybase.Form.RecordsetClone
    Set rst1 = Forms!frm_BIA!frm_SignOff.Form.RecordsetClone
    
    'find the current record
    'rst1.FindFirst "ID = " & Me.ID
    
    rst2.MoveLast
    Do While Not rst2.EOF
    If rst2.AbsolutePosition = rst1.AbsolutePosition Then
    rst2.Edit
    rst2!Process = Me.Process
    rst2.Update
    rst3.Edit
    rst3!Process = Me.Process
    rst3.Update
    rst4.Edit
    rst4!Process = Me.Process
    rst4.Update
    rst5.Edit
    rst5!Process = Me.Process
    rst5.Update
    rst6.Edit
    rst6!Process = Me.Process
    rst6.Update
    rst7.Edit
    rst7!Process = Me.Process
    rst7.Update
    rst8.Edit
    rst8!Process = Me.Process
    rst8.Update
    rst9.Edit
    rst9!Process = Me.Process
    rst9.Update
    rst10.Edit
    rst10!Process = Me.Process
    rst10.Update
    rst11.Edit
    rst11!Process = Me.Process
    rst11.Update
    
    Exit Do
    Else
    rst2.MoveNext
    rst3.MoveNext
    rst4.MoveNext
    rst5.MoveNext
    rst6.MoveNext
    rst7.MoveNext
    rst8.MoveNext
    rst9.MoveNext
    rst10.MoveNext
    rst11.MoveNext
    
    End If
    Loop
    rst1.Close
    rst2.Close
    rst3.Close
    rst4.Close
    rst5.Close
    rst6.Close
    rst7.Close
    rst8.Close
    rst9.Close
    rst10.Close
    rst11.Close
    
    Set rst1 = Nothing
    Set rst1 = Nothing
    
    End Sub
    Last edited by MMcCarthy; Nov 6 '10, 02:14 PM. Reason: Adding code tags
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    Joseph, why don't you strip out all the irrelevant code from this (most of it) and come back with a question that's clearly asked and pertaining to the problem code only.

    I expect once you tidy it up a bit your problem will become obvious anyway.

    Comment

    • hpesoj
      New Member
      • Nov 2010
      • 3

      #3
      i have 5 subform , when i enter data in subform 1 it should copy data to subform 2 to subform 5. when i write this code it was working fine, but now i get a error message "Run-time error 3021. No current record"

      Code:
      Private Sub Process_AfterUpdate() 
      Dim db As DAO.Database 
      Dim rst3 As DAO.Recordset 
      Dim rst2 As DAO.Recordset 
      Dim rst1 As DAO.Recordset 
        
      
      Set rst3 = Forms!frm_BIA!frm_endtoendprcs.Form.RecordsetClone 
      Set rst2 = Forms!frm_BIA!frm_prcscrticl_crtria_crtocatybase.Form.RecordsetClone 
      Set rst1 = Forms!frm_BIA!frm_SignOff.Form.RecordsetClone 
        
      'find the current record 
      'rst1.FindFirst "ID = " & Me.ID 
        
      rst2.MoveLast 
      Do While Not rst2.EOF 
      If rst2.AbsolutePosition = rst1.AbsolutePosition Then 
      rst2.Edit 
      rst2!Process = Me.Process 
      rst2.Update 
      rst3.Edit 
      rst3!Process = Me.Process 
      rst3.Update 
        
      Exit Do 
      Else 
      rst2.MoveNext 
      rst3.MoveNext 
      
        
      End If 
      Loop 
      rst1.Close 
      rst2.Close 
      rst3.Close 
        
      Set rst1 = Nothing 
      Set rst1 = Nothing 
        
      End Sub
      Last edited by NeoPa; Nov 7 '10, 01:15 AM. Reason: [CODE] tags added.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32661

        #4
        This has got even less explanation in than the first attempt, but I see you've stripped some code out, so I'll take it that you're trying at least.

        Now I've added the CODE tags again for you, can you tell me which line (post the number) is highlighted when the error comes up?

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          Looking at it some more I think maybe your form setup might be a problem. Your references certainly appear to be.

          Please do as asked in my post #2 and explain what is going on with your forms. What is a subform of what, and what are the names of the SubForm controls where they are used, and which forms are these controls on?

          Remember, it's your job to post the question. If you can't spend the effort to post the information properly then I'm not going to waste much more time on this.

          Comment

          • hpesoj
            New Member
            • Nov 2010
            • 3

            #6
            To precise it more....

            Main form - frm_BIA
            Subform - frm_endtoendprc s
            Subform - frm_prcscrticl_ crtria_crtocaty base
            Subform - frm_SignOff

            In frm_SignOff I have a field name process, when i enter the process name in Signoff, the process detail should display in other subform frm_endtoendprc s and frm_prcscrticl_ crtria_crtocaty base.

            when i run the code Afterupdate in frm_SignOff - Process field. i get the error message in "rst2.MoveL ast" line.

            Comment

            • MMcCarthy
              Recognized Expert MVP
              • Aug 2006
              • 14387

              #7
              OK in simple terms.

              This subform (frm_BIA!frm_pr cscrticl_crtria _crtocatybase) does not contain any records.

              The only reason you would be getting this error on rs2.MoveLast is if there are no records in this recordset.

              You need to figure out why there are no records.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32661

                #8
                I suppose you are under the impression you have answered the questions asked in my post, yet a quick check shows that subform control names are still missing. There is also no information related to what data is associated with any of your forms. I'm afraid that with that level of care (not even providing the specific info requested, let alone all relevant info), even after being reminded, I'm not interested in spending any more time on this than I already have.

                Mary's post is correct of course. That should be enough to start you in the right direction. We could have been so much more help with the information posted though I expect.

                Good luck with your project.

                Comment

                Working...