Duplicate a record?

FISHiEE

Fish obsessive
Local time
Today, 20:18
Joined
Nov 12, 2004
Messages
86
Hi. Hopefully a simple one this.

Is there some code that will duplicate an existing record in a table? I want to copy exactly an existing record (except the autoNumber field which I hope will generate ok for the duplicate?) and then change a couple of the field values based on data on the form. I can adjust the record once it's created ok, but can'e find a short way to create the duplicate. I think I could create a new record and then copy the values field by field, but hopefully there is a more efficient way to duplicate a record?

Thanks in advance.

John
 
There may well be an easier way but...

You could set the default of each field to the value of the last record like so


If Not IsNull(Me.ListCodeID) Then
Me.ListCodeID.DefaultValue = "='" & Me.ListCodeID & "'"
'For text fields 'Me.Operatorid.DefaultValue = "='" & Me.OperatorID & "'"
'For date fields 'Me.Operatorid.DefaultValue = "=#" & Me.Operatorid & "#"
'For number fields 'Me.Operatorid.DefaultValue = "=" & Me.Operatorid
 
Hm... that sounds a bit long winded... and I'd have to re-set the defaults again afterwards. I hoped there might just be a one-line piece of code to do this?

Maybe that's just wishful thinking tho?
 
How about using the wizard to create a button that will copy an existing record.
 

Users who are viewing this thread

Back
Top Bottom