Here's the code that Access generates if you create a button using the Command Button Wizard and assign the
Duplicate Record function to it.
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
-
On a Single Form or Continuous Form you can place it behind a command button. On a Datasheet form you need to place it on something like the DoubleClick event of a text control.
If any of the components of your row is Primary Key or set to no duplicates in the table definitions, after Access inserts the copy you must change the data in these controls before saving the newly created record, otherwise Access will throw an error and the new record won't be saved.