I have a Microsoft Access 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.
ArchiveConn.Exe cute "INSERT INTO rsTransactionAr chive rsTransaction" results in "Syntax error in INSERT INTO statement". How should I proceed with this?
I have tried this:
Nothing is copied to Archive.
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 tblTransaction WHERE TransactionID = " & cboID.Text, Conn 'Conn is connection to Database rsTransactionArchive.Open "tblTransaction", ArchiveConn 'ArchiveConn is connection to Archive ArchiveConn.Execute "INSERT INTO rsTransactionArchive rsTransaction" End Sub
I have tried this:
Code:
Private Sub cmdArchive_Click()
Call OpenArchive
Dim rsTransactionArchive As New ADODB.Recordset
rsTransactionArchive.Open "tblTransaction", ArchiveConn, , adLockOptimistic
ArchiveConn.Execute "INSERT INTO tblTransaction SELECT * FROM tblTransaction WHERE TransactionID = " & CInt(cboID.Text) & " IN ('Project.mdb')"
End Sub
Comment