H
Holly
I am trying to duplicate an entire record with a new key without listing
every field (too many). I tried this, but it didn't work. There must be a way!
strSql=Select statement to select record to copy
Set rstSaved = mydb.OpenRecordset(strSql, dbOpenSnapshot)
With rstSaved
Set rstNew = mydb.OpenRecordset("Proposal", dbOpenDynaset)
rstNew.AddNew
rstNew!Key1 = Key1
rstNew!Key2 = Key2
For Each fld In .Fields
If fld.Name <> Key1 And fld.Name <> Key2 Then
rstNew.Fields(fld.Name) = (fld.Value)
End If
Next
rstNew.Update
rstNew.Close
.Close
End With
every field (too many). I tried this, but it didn't work. There must be a way!
strSql=Select statement to select record to copy
Set rstSaved = mydb.OpenRecordset(strSql, dbOpenSnapshot)
With rstSaved
Set rstNew = mydb.OpenRecordset("Proposal", dbOpenDynaset)
rstNew.AddNew
rstNew!Key1 = Key1
rstNew!Key2 = Key2
For Each fld In .Fields
If fld.Name <> Key1 And fld.Name <> Key2 Then
rstNew.Fields(fld.Name) = (fld.Value)
End If
Next
rstNew.Update
rstNew.Close
.Close
End With