Easiest way to copy/add identical record.

  • Thread starter Thread starter ThomasAJ
  • Start date Start date
T

ThomasAJ

I want to store a record with several hundred fields to another identical
table before I delete that record.

Can I enumerate each field like:
for each field in table1

Can someone help me with the code please.

Or is there an easier way?
 
You can do it, but before you do, please consider whether this table is
normalized.

If you have 'several hundred fields', there is no way you have a correct
database design. IMHO, you could make better use of your time by reading up
on normalization rather than by writing code to try to work around the real
problem.

If you want to do it anyway, OpenRecordset on a SQL string that selects just
the one record, and AddNew to the RecordsetClone. You can then loop through
the Fields of the Recordset.

Here's an OpenRecordset() example:
http://allenbrowne.com/func-DAO.html#DAORecordsetExample
To loop through the fields of the Recordset, add:
Dim fld As DAO.Field
For Each fld In rs.Fields
Debug.Print fld.Name
Next
 
Back
Top