Partially cloning a record

  • Thread starter Thread starter BobRoyAce
  • Start date Start date
B

BobRoyAce

I have a form whose Default View is specified to be Continous Forms. In the
detail section I have a row of edit controls which are bound to fields in
the form's underlying table. Additionally, I have a little button (to the
far left) that appears for each record. What I want to do is, when the user
clicks on this button, copy the record on the "line" it's on, append it to
the underlying table, have the record appear in the "grid", and position the
user on the first field for the new record. I will not be copying all of the
fields on the existing record into the new one...just certain fields.

How would I actually make something like this happen (i.e code)?

Note: Assume there is are no normalization issues with what I'm doing.
 
Simplest approach would be to create a new record in the RecordsetClone of
the form.

Something like this (aircode):

If Me.Dirty Then 'Save any changes first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record to duplicate."
Else
With Me.RecordsetClone
'Create the new record
.AddNew
!SomeField = Me.SomeField
!AnotherField = Me.AnotherField
'etc for the fields you wish to copy.
.Update

'Make the new record the current one in the form.
.Bookmark = .LastModified
Me.Bookmark = .Bookmark
End With
End If
 
Back
Top