By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

Duplicate records to different tables

P: n/a
Friends, I know I should not be doing this but I find it very usefull.
I need to duplicate records from one table to another table.
My table is named CLIENTS and has a field named FILENUMBER.
When I add a record in this field I would like that it automatically
is duplicated to another table which has a field named ACCOUNTNUMBER.
I will use the after update event.

Presently I am using a similar code to duplicate the field FILENUMBER
in the same table:

Dim MyDb As DAO.Database, MyRs As DAO.Recordset
Dim strCode As String
Dim strFilter As String
Set MyDb = CurrentDb
Set MyRs = MyDb.OpenRecordset("CLIENTS")
MyRs.AddNew
MyRs!SSN = Forms!CLIENTS!FILENUMBER
MyRs.Update
strCode = DMax("[ID]", "Clients")
strFilter = "(([ID] = " & strCode & ")) "
DoCmd.ApplyFilter , strFilter
End If

Any help?
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
jp***@tin.it (Paolo) wrote in message news:<9f*************************@posting.google.c om>...
Friends, I know I should not be doing this but I find it very usefull.
I need to duplicate records from one table to another table.
My table is named CLIENTS and has a field named FILENUMBER.
When I add a record in this field I would like that it automatically
is duplicated to another table which has a field named ACCOUNTNUMBER.
I will use the after update event.

Why not just use the BeforeInsert event to capture all the values and
then write them to a separate table?

Sub MyForm_BeforeInsert()
'open the database connection
'open the destination table for insert
'add the record
'close the recordset
'clean up
End Sub

If you wanted, you could wrap the whole thing in a transaction... use
the workspace object to get to it.
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.