• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

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.

0
Shaley
Asked:
Shaley
  • 5
  • 4
1 Solution
 
BennyBunnyCommented:
you may do

dim field as new field

for each field in rst1.fields

 .....
next
0
 
BennyBunnyCommented:
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
0
 
ShaleyAuthor Commented:
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.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ShaleyAuthor Commented:
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.
0
 
BennyBunnyCommented:
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

0
 
ShaleyAuthor Commented:
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.
0
 
BennyBunnyCommented:
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

0
 
BennyBunnyCommented:
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



0
 
ShaleyAuthor Commented:
Thanks for your help
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now