+ Reply to Thread
Results 1 to 11 of 11

Count Number Of Records Returned by ADODB

  1. #1
    Forum Contributor
    Join Date
    10-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    110

    Count Number Of Records Returned by ADODB

    Hi All,

    I have a Macro in which I am fetching data from a sheet and pasting it into another sheet using ADODB.

    The code is working perfectly but what else I want is the count of number of records returned.

    Please have a look at the attached Macro file.

    Can anybody tell me what all changes I need to make so that I can count of records returned into Recordset.

    Thank you!
    Attached Files Attached Files
    Last edited by Tejas.T; 12-12-2012 at 09:01 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Count Number Of Records Returned by ADODB

    Hi-

    Why not use the excel rows.count?
    or if you really want via sql then
    Please Login or Register  to view this content.
    Regards,
    Event

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Count Number Of Records Returned by ADODB

    Did you try the suggestions on your other thread? You really shouldn't be using ADO like this and certainly not for a client. You shouldn't hand over buggy, memory leaking code.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Count Number Of Records Returned by ADODB

    You could do the filter with auto or advanced filter.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    10-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Count Number Of Records Returned by ADODB

    @Kyle123
    Thank you for your suggestion again. In the final deliverable I am querying from another workbook only.

    @Kyle123 & even21
    I think there is some property like RecordCount with RecordSet. Can you guide me how to use it?

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Count Number Of Records Returned by ADODB

    Like this, but as you're still learning to use ADO, you'd be better with early binding so that you have the global constants and intellisense

    Please Login or Register  to view this content.

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Count Number Of Records Returned by ADODB

    if you put column headers in A6:B6 on macro sheet you can also use
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  8. #8
    Forum Contributor
    Join Date
    10-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Count Number Of Records Returned by ADODB

    @JosheP & @Kyle123:

    Thank you for your answers. As per http://support.microsoft.com/kb/319998, Microsoft suggests using SELECT INTO to avoid memory leak.
    So does it apply to INSERT INTO also??

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Count Number Of Records Returned by ADODB

    There is no issue with either as long as the workbook is closed. You shouldn't really be querying open workbooks.

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count Number Of Records Returned by ADODB

    SELECT INTO only bypasses the memory issue in the sense that you are supposed to use it to export your source data to a new closed workbook and then query that, thereby avoiding the issue caused by repeated querying of an open workbook. Using it to create a new sheet in the open workbook would not help you. In that sense INSERT INTO would help only if you inserted the data into an existing closed workbook.

  11. #11
    Forum Contributor
    Join Date
    10-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Count Number Of Records Returned by ADODB

    Ok thank you experts!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1