Link to home
Start Free TrialLog in
Avatar of Shaley
Shaley

asked on

Single record from ADO recordset

Hi. I want to take a given record (in this case the last record) from an ADO recordset and put it into another recordset.  Is there any easy way of doing it other than:-

rst2!Field1 = rst1!Field1

Thanks for your help.

Avatar of BennyBunny
BennyBunny

you may do

dim field as new field

for each field in rst1.fields

 .....
next
because der is no "Record" object on ADO u may try
if the recordsets have the same field names...u can something like this:

For each field in rst1.fields
     rst2.field(field) = field(FIELDNAME).Value
next
Avatar of Shaley

ASKER

The recordset I am copying to is set to "Nothing".  I just want to take one record out of the recordset and use that to create a new recordset.

Therefore I do not want to have to create all the field details for the recordset.  I could just delete all records apart from the last but I was hoping there was a more efficient way of doing it.
Avatar of Shaley

ASKER

The recordset I am copying to is set to "Nothing".  I just want to take one record out of the recordset and use that to create a new recordset.

Therefore I do not want to have to create all the field details for the recordset.  I could just delete all records apart from the last but I was hoping there was a more efficient way of doing it.
ok in that case try to add the fields with the add method

for each field in rst1
  rst2.addnew field.name
next
and then fill it with an other for each field in

Avatar of Shaley

ASKER

Your code as it stands won't work but I can modify it so it can, but again it's not quite what I'm really after.  

What you are suggesting will probably not be any more efficient than deleting all but the record I want - especially as the recordset being returned will be a maximum of 10 records.
yea but as i said there is no record object on ADO
so u have to add manually
but maybe u can do it in one for each next
like
for each field in rst1.fields
  rst2.addnew field.name,field.value
next

ASKER CERTIFIED SOLUTION
Avatar of BennyBunny
BennyBunny

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shaley

ASKER

Thanks for your help