Wrong record count

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Terryvanduzee
    New Member
    • Oct 2009
    • 6

    Wrong record count

    Hello

    In my form load event, I have the value of a text box that displays the count of the records in the form. The number always displays 40, where a physical count of the records is 73.

    Code:
    Me.Text7.Value = [Forms]![frm_All_Mattresses_Main].[frm_All_Matt_frm_subform].Form.Recordset.RecordCount
    Any suggestions?

    Thank you
    Terry
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    This behavior is explained clearly with the solution in this link: Recordset.Recor dCount Property.

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by Terryvanduzee
      Hello

      In my form load event, I have the value of a text box that displays the count of the records in the form. The number always displays 40, where a physical count of the records is 73.

      Code:
      Me.Text7.Value = [Forms]![frm_All_Mattresses_Main].[frm_All_Matt_frm_subform].Form.Recordset.RecordCount
      Any suggestions?

      Thank you
      Terry
      You can also use DCount("*") on the Record Source of the Sub-Form with a Where criteria rto obtain an accurate Count.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32634

        #4
        When Recordsets are opened, it's not always practical to read the whole dataset into memory at the outset. It is not always necessary and takes up valuable resources. When you try to get the count of the records before they're all loaded in, the value is inaccurate (as you've found). The solution to this is to move the recordset pointer (or current record) to the end and then back to the start. This ensures all records are loaded and the correct count value is returned. Be careful only to do this in situations where you're confident that the recordset is not too large though. The delay can make for a quite unfriendly user experience if it is.

        Comment

        • Terryvanduzee
          New Member
          • Oct 2009
          • 6

          #5
          Thank you...
          Works great. I had forgotten about the movelast

          Again, thank you
          Terry

          Comment

          Working...