Results 1 to 3 of 3

Thread: rs.recordcount reporting wrong number of records

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    47

    rs.recordcount reporting wrong number of records

    i got an access db with this query, called qryallbooks, inside the db:

    SELECT tblBook.BookID, tblBook.BookName, tblBook.AuthorFirstName, tblBook.AuthorSecondName, tblBook.BookEdition, tblBook.ISBN, tblBook.Price, tblBook.WebLink, tblBook.DeweyCode
    FROM tblBook;


    then in my vb6 app i do this:

    Set qd = dB.QueryDefs("qryAllBooks")
    Set rs = qd.OpenRecordset
    msgbox rs.recordcount

    i get 1, however the table clearly has 2 records, i can tell coz i opened up the tbl in access and had a look. i also can do rs.movenext 2 times with no errors.

    what is going on? how do i make rs display the right number of records?

  2. #2
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313

    Re: rs.recordcount reporting wrong number of records

    In DAO you need to do an rs.MoveLast to get the right count.
    This might be of interest:
    http://www.microsoft.com/officedev/tips/rscount.htm

    VB Code:
    1. Set qd = dB.QueryDefs("qryAllBooks")
    2. Set rs = qd.OpenRecordset
    3. rs.MoveLast
    4. rs.MoveFirst
    5. msgbox rs.recordcount

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    47

    Re: rs.recordcount reporting wrong number of records

    that is so strange, thnx u.

Posting Permissions

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



Click Here to Expand Forum to Full Width