Q re copying Recorset

D

Dick Penny

I have abstracted several lines below from a "copying recordset example." If
typos, please bear with me.
My Q is, what is "ResID", a field name in old/first recordset? If so, how
does this copy the whole record?
I thought one had to enumerate the fields to be copied?

Do While Not OldRes.EOF
Addit:
NewRes.AddNew
NewRes![ResID] = OldRes![ResID]
NewRes.Update
DoEvents
Msgbox "blah blah blah"
Loop
Msgbox "blah#2 blah#s"
OldRes.Close
NewRes.Close
db.Close
((no comments about not copying & pasting, please))
 
D

Dirk Goldgar

Dick Penny said:
I have abstracted several lines below from a "copying recordset
example." If typos, please bear with me.
My Q is, what is "ResID", a field name in old/first recordset?

Yes. Presumably it's the primary key field, but in principle it's just
some field in the recordsets.
If so, how does this copy the whole record?

It doesn't, unless there's only the one field in the recordset. If this
was given as an example, the author should probably have included a
comment along the lines of

' ... repeat similarly for other fields ...
I thought one had to enumerate the fields to be copied?

One does, either by name or, if the recordsets are identical in
structure, by looping through the Fields collection.
 
A

ALESSANDRO Baraldi

Dick Penny said:
I have abstracted several lines below from a "copying recordset example." If
typos, please bear with me.
My Q is, what is "ResID", a field name in old/first recordset? If so, how
does this copy the whole record?
I thought one had to enumerate the fields to be copied?

Do While Not OldRes.EOF
Addit:
NewRes.AddNew
NewRes![ResID] = OldRes![ResID]
NewRes.Update
DoEvents
Msgbox "blah blah blah"
Loop
Msgbox "blah#2 blah#s"
OldRes.Close
NewRes.Close
db.Close
((no comments about not copying & pasting, please))

Yes ResID is Filed Name in Old and New recordset.
If you have more than one Field you must cilce trought Fields
collection each Record.

dim fld as DAO.Field
Do While Not OldRes.EOF
Addit:
NewRes.AddNew
for each fld in NewRes.Fields
NewRes.Fields(fld.name)=OldRes.Fileds(fld.name) 'I presume they
have the same name
Next
NewRes.Update
DoEvents
'Msgbox "blah blah blah"
Loop
Msgbox "blah#2 blah#s"
OldRes.Close
NewRes.Close
db.Close


Hi.

Alessanrdro(IT)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

searching for corrupted data 4
Searching for Corrupt Data 13
Corrupt Table 1

Top