Results 1 to 3 of 3

Thread: [RESOLVED] Cannot use 'RecordCount' property...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    15

    Resolved [RESOLVED] Cannot use 'RecordCount' property...

    Hi all,

    I am using VB6 and i just cannot seem to get the RecordCount property of the recordset correctly. For example, when I tried using this property on form_load(), it always gives me a value of -1 even though the recordset contains 5 or 6 objects.

    I need this property for two uses. Firstly to count and display the number of matching records found when the 'Search Results' form is loaded and secondly, to determine the no. of records left in the recordset when a record is deleted and if no record is left, then to close the form using form.hide method.

    Can anyone please help me with this? Any help will be greatly appreciated. Thanks in advance for any help.

  2. #2
    New Member
    Join Date
    Sep 2006
    Posts
    6

    Re: Cannot use 'RecordCount' property...

    what style database?
    what is your curser location set to?

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Cannot use 'RecordCount' property...

    I suspect CundiRob has got the issue - cursor location. The recordcount is -1 if the actual amount of records is currently unknown, which is the case for server-side cursors.

    However, based on what you said you have no need whatsoever for the recordcount anyway - simply using the .BOF and .EOF properties would work for you, which would be quicker, simpler code, and use less memory. eg:
    VB Code:
    1. 'displaying records
    2. rs.Open ...
    3.  
    4. Do While Not rs.EOF
    5.   'use the recordset values here
    6.   rs.MoveNext
    7. Loop
    8.  
    9. 'checking if there are records remaining:
    10. If rs.BOF and rs.EOF Then
    11.   MsgBox "no records remaining in the recordset!"
    12. End If

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