Results 1 to 7 of 7

Thread: Copy a record from one database to another

Threaded View

  1. #1

    Thread Starter
    Lively Member Phantom1's Avatar
    Join Date
    Nov 2011
    Posts
    64

    Exclamation Copy a record from one database to another

    I have a database called Database which the VB6 program uses. I want to archive specific transaction records, i.e. send them from Database to another database called Archive which is of the same structure (same table names, fields, relationships) as Database.

    The user selects an ID from a combo box and the matching record is archived on clicking on the command button cmdArchive.

    This is what I have written so far.

    Code:
    Private Sub cmdArchive_Click()
    Dim rsTransaction as New ADODB.Recordset, rsTransactionArchive as New ADODB.Recordset
    Call OpenDatabase 'function to open Database
    Call OpenArchive 'function to open Archive
    rsTransaction.Open "SELECT * FROM tblProductTransaction WHERE TransactionID = " & cboID.Text, Conn 'Conn is connection to Database
    rsTransactionArchive.Open "tblProductTransaction", ArchiveConn 'ArchiveConn is connection to Archive
    ArchiveConn.Execute "INSERT INTO rsTransactionArchive rsTransaction"
    End Sub
    ArchiveConn.Execute "INSERT INTO rsTransactionArchive rsTransaction" results in "Syntax error in INSERT INTO statement". How should I proceed with this?
    Last edited by Phantom1; Apr 28th, 2012 at 03:58 AM.
    Learning to Program on Earth until I go into Outer Space...

Posting Permissions

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



Click Here to Expand Forum to Full Width