Results 1 to 9 of 9

Thread: Passing records between recordsets

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Passing records between recordsets

    Can I fill an ADO recordset with records from another ADO recordset.

    I want to do tests on individual records in a set and those that pass should be sent to another recordset.

    I am sure this will be easy I just can't figure it out.

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    a few questions...

    do you want to move or copy the records accross???

    do you want to move/copy each record as you assess it...

    do you want to do it in bulk, i.e. track which records to copy/move then do them all at once later on..?

    also assuming the two recordsets point to different tables/queries then why not just copy the records accross to the underlying table in the second recordset using SQL or something, then at the end of the whole process just refresh the recordset...
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    Originally posted by darre1

    do you want to move or copy the records accross??? -
    Copy

    do you want to move/copy each record as you assess it... -
    Yes

    do you want to do it in bulk, i.e. track which records to copy/move then do them all at once later on..? -
    One at a time

    also assuming the two recordsets point to different tables/queries then why not just copy the records accross to the underlying table in the second recordset using SQL or something, then at the end of the whole process just refresh the recordset...
    The tests I need to perform cannot be done with SQL, I have a calculation class that converts values (39 of them into 5 different ones) these values are then compared with pre-defined ranges.

  4. #4
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    how many tests have to be performed...?

    for example lets say you have to do 5 tests.
    i would personally do it like this.

    open the recordset initially with every record in the table.

    filter out the records that fail test 1.

    then apply another filter on top to filter out the records that fail test 2.

    etc etc...

    this is more efficient than just doing 1 record at a time, since some of the records wont need to be tested on all of the tests anyway.

    once you have applied all filters go through the remaining records and copy them accross either using SQL INSERT INTO statement or you could use rst.AddNew and then set the values that you want to add.


    can you give a better example of what you are having trouble with...do you want to copy records to another table???

    do the other recordset point to the same table or a different one etc......?
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  5. #5

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479
    I need a recordset to pass to a class that uses it to fill a FlexGrid.
    But the recordset I get from the database has too many records, so I want to declare another recordset and only put some of the records from the 1st set into it.

    The 2nd recordset will not be connected to a database, it is just a method of holding data temporarily.

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Can you hold the excess records in an array?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  7. #7

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Well

    Originally posted by James Stanich
    Can you hold the excess records in an array?
    Yes I could but I was hoping there would be a lazy way.

  8. #8
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Re: Re: Well

    Originally posted by GlenW
    Yes I could but I was hoping there would be a lazy way.
    The solution is not always a simple one. Sorry.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  9. #9
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    in that case instead of using 2 recordsets, why not just use one with lots of filters in that you then send to your class?
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

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