Counting records in open subform. Code updating nonstop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    Counting records in open subform. Code updating nonstop

    When i use this code to count the number of records on display in a specific subform in the "txtRecordN o" field that is open now, it seems to "update" all the time as the cursor changes every second and i am unable to add new records on mainform, untill i click in one of the fields of this Subform. Then it settles down. Otherwise it works 100% when i add records in the subform.
    pls help

    Code:
    Private Sub Form_Current()
    
        Dim rst As DAO.Recordset
        Dim lngCount As Long
    
        Set rst = Me.RecordsetClone
    
        With rst
            .MoveFirst
            .MoveLast
            lngCount = .RecordCount
        End With
        
    'Show the result of the record count in the text box (txtRecordNo)
    
        Me.txtRecordNo = lngCount
    End Sub
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    You should remember to include a
    Set rst=nothing
    at the end of your code. However this has nothing to do with the issue at hand.
    Do you have other code running in main form or subform?
    Which version of access are you using?

    Comment

    Working...