Duplicating records

tuna

Registered User.
Local time
Today, 15:22
Joined
Mar 31, 2010
Messages
27
Hi, I want to write a sub to duplicate a record in any table, i.e., the only parameters are the table name and sql criteria like so: DuplicateFunc(strTableName As String, strSQLCriteria As String). I've started by using "INSERT INTO" statements but that requires knowing the number of fields of the table whose record you want to duplicate.

I want to provide a quick duplication method for the user across a number of tables. (This is because we have a system that logs both invoices and transactions so the two can be checked against each other to identify outstanding settlements, and a duplication system allows us to log transactions quickly when they exactly match the original invoice). I have a few more tables in similar situations, so I need a duplication function that works for any table so I don't have to write a new "INSERT INTO" statement for each table to account for their different fields.

Thanks very much.
 
Try something like

strSQL = "insert into "&tableName&" select * from "&tableName&" where "&conditions

You don't have to specify the fields.
 

Users who are viewing this thread

Back
Top Bottom