Modify a resulting ADO.Recordset

  • OzGrid / Et Al.


    I have a query ( stored in access, called via VBA in excel ). Now the query as created returns a recordset which has 3 fields per record.


    For this purpose say ( FieldA, FieldB, FieldC ).



    What I want to know is this. After executing the stored procedure and getting back the recordset with 3 fields. Is is possible to remove FieldA and FieldB from the recordset. Which would leave me with a single column of information. Yes I can create a query which does this for me. But my database is quickly becomming populated with hundreds of different queries so I'm looking for ways to use existing queries.

  • Re: Modify a resulting ADO.Recordset


    If you are using ADO, you could do something along the lines of;



    This is untested but this should meet what you need. Again, if you are using ADO, you might also look at the .GetRows() method.

  • Re: Modify a resulting ADO.Recordset


    Was hoping for a solution that in which I wouldn't have to loop and read out each record.

  • Re: Modify a resulting ADO.Recordset


    I wonder!!


    Can you run a "SQL" command agains an existing recordset. Seems like it should be possible. I've just never seen it done.

  • Re: Modify a resulting ADO.Recordset


    Look at the .GetRows() method, it returns an array from your recordset and allows you to pull in only the field you are wanting.



    This might be useful for you if you are not wanting to loop through the records.

  • Re: Modify a resulting ADO.Recordset


    Quote from iwrk4dedpr

    I wonder!!


    Can you run a "SQL" command agains an existing recordset. Seems like it should be possible. I've just never seen it done.


    No, you cannot, at least not with ADO, you can Filter it, but you cannot query against an existing recordset.

  • Re: Modify a resulting ADO.Recordset


    Bnix,


    Thanks. I should have known that the .GetRows might have some properties /methods.



    Thanks, I'll be looking into this. Looks like it might do the trick.



    I'm posting another question. Different topic maybe you'd be so kind as to share some knowledge on the subject.