Consulting

Results 1 to 5 of 5

Thread: Can you query a RECORDSET using SQL

  1. #1
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location

    Can you query a RECORDSET using SQL

    Wondering if one can do a SQL query on a Recordset, I've searched and Googled, thus far found nothing useful. Currently my report project grabs data from an Access DB using SQL and does some aggregate on the data, works. What I am having trouble is that I like to do another SQL on that same Recordset, I am having trouble doing that. The way I am overcoming this problem is to create a temp table then do a SQL on that temp table. Just wondering if I can skip that step and do a direct query right on the Recordset.

    Thanks.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Maybe RS.Filter will do what you want? Take a look at my blog post, https://blogs.msmvps.com/xldynamic/2...-has-no-class/, it talks of disconnected recordsets, but filter works for a normal recordset.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Thank you, xld, I don't think it will do. What I need to do with the Recordset is to run an aggregate SQL on it as well. For that, this is why I don't think the Filter would work. My first query did the initial aggregate, because I am collapsing different body parts (face, ear....to a category all Head), this gives me multiple Head groupings. The second SQL, I run another aggregate to give me one count of the Head injury, hence I would like to query the Recordset. So, I dumped the Recordset into a temp table then do a query to overcome my problem. Hoping for a more direct way to solve my problem....

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Could you not filter it by your criteria and then a simple aggregation?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    i suppose you could, but I will need to filter multiple times. If this is the case, I did rather query my temp table, since this is just a simple group by query. Of course, unless i am totally out to lunch....

Posting Permissions

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