How to know records in a DAO recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jasperz01
    New Member
    • Jun 2007
    • 20

    How to know records in a DAO recordset

    Hi,

    I have a DAO.Recordset wich is filled with data from a query in Access. How can I know how many records there are in this recordset?

    so far I have this:

    [code=vb]
    Dim strSQL As String
    Dim i As Integer
    Dim iNumCols, iNumRows As Integer


    ' This should be the final SQL cmd
    strSQL = "SELECT * FROM SBB_General_Pur pose WHERE Datum BETWEEN " & ToDate & " AND " & TillDate & ";"


    Set db = CurrentDb()
    Set rs = db.OpenRecordse t(strSQL)

    If Not rs.BOF And Not rs.EOF Then ' it has records

    iNumCols = rs.Fields.Count
    iNumRows = rs.RecordCount
    [/code]

    However, iNumRows stays at 1, so I guess this is the 1st record, not the total ammount of records. Anyone who knows a trick to get this number?

    Thanks in advance,

    Jasper
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Move to the last record and then use the RECORDCOUNT property.

    This will solve your problem.

    Comment

    • jasperz01
      New Member
      • Jun 2007
      • 20

      #3
      Originally posted by debasisdas
      Move to the last record and then use the RECORDCOUNT property.

      This will solve your problem.
      And how do I move to the last record? I'm kind of new to recordsets, so forgive me for asking such a simple question :)

      Regards,

      Jasper

      Comment

      • jasperz01
        New Member
        • Jun 2007
        • 20

        #4
        Originally posted by jasperz01
        And how do I move to the last record? I'm kind of new to recordsets, so forgive me for asking such a simple question :)
        Never mind, it was really simple indeed. A rs.MoveLast did the trick. Thanks :)

        Comment

        Working...