Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: Recordset.recordCount

    I have following code :

    Code:
    Public Sub mySUB (value1, value2)
        
    Dim rs As New ADODB.Recordset
    
    strSQL = "SELECT * FROM tblMyTable " & _
                  "WHERE field1 = " & value1 & _
                  " AND field2 = " & value2
                       
    rs.Open strSQL, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
        
    Debug.Print rs.RecordCount
    
    End Sub
    debug.print always shows -1 however there are 3 records in the resultset

    Why can't I retrieve the number of records.


    I already tried this :
    Code:
    rs.moveLast
    Debug.Print rs.RecordCount
    but it won't work either.
    Any suggestions ?

    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Try adding rs.MoveLast after the rs.Open... statement

  3. #3
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    good solution

    sometimes if you are only looking for records that are edited I also will do the following

    dim x as integer
    x = 0



    then within the code that is editind a record I insert

    x = x + 1


    after going through the recordset

    i close and killl the recordset

    then do something like

    Msgbox "There were " & X & " records edited for this process."

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    Sorry, I missed one other thing
    You can't use .Recordcount with ForwardOnly cursors.
    Change adOpenForwardOnly to adOpenStatic

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •