Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004

    Unhappy Unanswered: Copying records from one database to another

    My code looks like this:
    Dim db As Connection
    Dim RS2 As Recordset

    Set db = New Connection
    db.CursorLocation = adUseClient
    db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\SESCOgx80\Databasebk\GX_DATA.MDB;"

    Set RS2 = New Recordset
    RS2.CursorType = adOpenKeyset
    RS2.Open "select * from INSPECT Order by InsDOI DESC", db, , adLockOptimistic

    DBEngine.Idle dbFreeLocks
    iRecCnt = RS2.RecordCount
    For iCnt = 1 To iRecCnt - 1
    RS2.Fields(iCnt).Value = RSPrimary.Fields(iCnt)

    When this code runs I get the error:
    "Run-time error '-2147217887(80040e21)'"
    "Multiple-step operation generated errors. Check each status value."

    The code will allow only two fields to be added to the buffer before the above error occurs.
    If I bypass the error and go to RS2.Update it does create the new record with the two fields.

    Anybody got any ideas. It would be much appreciated!

  2. #2
    Join Date
    Jan 2004
    You are running the loop for number of records times.
    If you want to copy all fields of one record set to another record set, you must rum the loop for number of columns times.
    So try changing the loop counter.


  3. #3
    Join Date
    Jan 2004

    Thumbs up Problem solved.

    You are right! I changed the loop to loop through the recordset fields count. However, this did not fix the problem.
    The problem turned out to be: I am displaying the local database in a grid. I passed the grid recordset as an object to the sub without thinking that the fields would not be in the same order as the server database because I used the data form wizard to populate the recordset. To solve the problem, I simply passed the key fields and created a new recordset. Now the fields match and the sub works. What confused me was the error message.
    Thanks very much for your help. I appreciate it very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts