Deplicate selected values in Forms (1 Viewer)

sadiq92

New member
Local time
Today, 17:16
Joined
Jun 4, 2020
Messages
29
Hello,

as you know when adding buttons on forms you can add many “ ready-make” buttons including duplicate record button. However, the duplicate button will duplicate all the values from the last record.

Is there a way I make the duplication occur only for selected fields and make the other fields empty???!!!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:16
Joined
May 7, 2009
Messages
19,169
if the record shown in form/table is the Duplicated record, not in New record,
you can just blank out the fields you don't want to be duplicated:

'code after running duplicate record
...
...
' blank out some fields
Me!Field1 = Null
Me!FieldX = Null
' save changes
Me.Dirty = False
 

sadiq92

New member
Local time
Today, 17:16
Joined
Jun 4, 2020
Messages
29
if the record shown in form/table is the Duplicated record, not in New record,
you can just blank out the fields you don't want to be duplicated:

'code after running duplicate record
...
...
' blank out some fields
Me!Field1 = Null
Me!FieldX = Null
' save changes
Me.Dirty = False

where I put this code?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:16
Joined
May 7, 2009
Messages
19,169
inside the code of your "ready-made" button (duplicate record).
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:16
Joined
Jul 9, 2003
Messages
16,244
I answered a post a while back about duplicating records in a sub-form. I gather that you want to duplicate records on the main form, so this might only be a curiosity for you.

If it's of Interest you can download it here:- https://gum.co/SubRecDuplicator for a limited time by using the coupon code:- freetodayonly

For more information about this method and way it was developed see my blog on Nifty Access here:-

 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:16
Joined
Feb 19, 2002
Messages
42,970
If you are working in a list type subform and you want to copy the value from the same field on the previous record, the keyboard shortcut is the same as it is in Excel.

CNTL-Quote

Keep in mind that in a properly designed table, you would almost certainly not have to do this. Perhaps the field(s) you are duplicating belong in the parent table or even an intermediate table.
 

Users who are viewing this thread

Top Bottom