Sorry, I misunderstood what you wanted.
When you set rstForm = Me.RecordsetClone, the recordset (rstForm) *usually*
opens with the first record as the current record; the current record could
be any record. so you have to find the record in rstForm, then copy it.
Also, it is really a good idea to check the .NoMatch property (I added the
lines) to make sure the record was found before the copy.
In the code there is a line:
rstForm.FindFirst "[TestID] = " & Me![lngTestID]
Change [TestID] to the name of the primary key field in the recordset
"rstForm".
Change [lngTestID] to the name of the control on the form that has the
primary key field as the control source.
NOTE: the name of the control should be differend than the field name!!!!
'---- Begin New Code ----------------
Private Sub Command0_Click()
Dim rstForm As DAO.Recordset, rstArchive As DAO.Recordset
Dim dbs As DAO.Database
Dim intField As Integer
'get a clone of the forms recordset
Set rstForm = Me.RecordsetClone
'get a recordset for your archive table
Set dbs = CurrentDb
Set rstArchive = dbs.OpenRecordset("ArchiveTable", dbOpenDynaset)
' locate the record in recordsetclone that is displayed in the form
' edit the following line:
' change [TestID] to the name of your primary field in the
recordsetclone
' change [lngTestID] to the name of the CONTROL on the form that has
' the primary field as the control source.
rstForm.FindFirst "[TestID] = " & Me![lngTestID]
'check that the record was located
If Not rstForm.NoMatch Then
'copy the fields across
With rstArchive
.AddNew
For intField = 0 To (rstForm.Fields.Count - 1)
.Fields(intField) = rstForm.Fields(intField)
Next
.Update
End With
Else
' something went wrong.....
MsgBox "ERROR - Record not found!!!"
End If
' also need to clean up
rstArchive.Close
Set rstArchive = Nothing
rstForm.Close
Set rstForm = Nothing
Set dbs = Nothing
End Sub
'------------End Code ----------------
Steve