copying recordsets

rwilson32

Registered User.
Local time
Today, 14:43
Joined
Jul 10, 2003
Messages
23
I have a database which has multiple users that are not connected. What I would like to do is make it possible for me to automate synchronization with these databases when they do come together. For example copy all the new records in a certain table to that same table in a different database without deleting any of the existing records. The only problem I have is the actual copying of the data. If I could find a way to copy a whole recordset instead of :
recordset1.addnew
recrodset1!field1 = recordset2!field1
recordset1!field2 = recordset2!field2
and so on

I would rather be able to say something like
recordset1.copyto recordset2
or something similar.

I have tried using append queries, but i get referential integrity errors when it tries to copy over and I think it would be easier for me to use recordsets.

Any help would be appreciated.

Thanks
 
You will still get the same RI error ... you must first resolve that. Look at your relationships and review your dependencies. If you are populating a 'Child' table, you must have the 'Parent' table populated with related records.
 
I resolved the RI error, now I just need to know how copy one recordset to another from code with out using append queries.
 
Hi,

As fas as I know, it's only possible with looping through the recordset.
But make it easy for yourself:

Code:
Public Function CopyRecordset(RstFrom As Recordset, RstTo As Recordset)
  Dim fld As Field
 
  Do Until RstFrom.EOF
    RstTo.AddNew
    For Each fld In RstFrom.Fields
      RstTo.Fields(fld.name).Vlaue = RstFrom.Fields(fld.name).value
    Next fld
    RstTo.Update
    RstFrom.MoveNext
  Loop
End Function
Sorry, didn't test it yet... ;)
 

Users who are viewing this thread

Back
Top Bottom