Results 1 to 27 of 27

Thread: Getting RecordCount [Resolved] (almost)

Hybrid View

  1. #1
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Getting RecordCount [Resolved] (almost)

    I'm not understanding what you mean by ran it about 8 times and what you mean by deleting everything.

    Are you creating a TEMP TABLE with the rows you want to process? Could you show some real code so I can grasp this a bit better?

    I'm not a VBA person - so maybe I'm confusing something in regard to that.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Getting RecordCount [Resolved] (almost)

    I just used count() to get a record count, and put it into a table.
    Here:
    VB Code:
    1. rs.Open "INSERT INTO TempTable (RecCount) " & _
    2.      "SELECT  Count(*)" & _
    3.      "From FarmingTemp", cn, adOpenKeyset, adLockOptimistic, adCmdText

    After I ran it, I had 8 records in the table, each with a different number of records in it. Then, I was getting the number from the table:

    VB Code:
    1. rs.Open "select RecCount from TempTable", cn, adOpenKeyset, adLockOptimistic, adCmdText

    I wanted to know what this was returning? Was it the last record, or the first?
    I just wanted to know a general rule of thumb as to how it all worked.

    Now, all is good, as I delete all records before I write any, so the problem won't arise again. I just wonder what would come up if I didn't delete all of the records each time.

    Was it the first record, or the last record?

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Getting RecordCount [Resolved] (almost)

    The "SELECT Count(*)" part gets you the number of records in the FarmingTemp table. So you
    should have 8 in your RecCount field for all 8 records.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Getting RecordCount [Resolved] (almost)

    Hmm. That makes sense, but I thought they were different numbers, and selecting the count only added one record. I'm going to do it again to see exactly what is happening. Thanks.

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