totn Access

MS Access 2007: Duplicate a record

This MSAccess tutorial explains how to set up a button to duplicate a record in a form in Access 2007 (with screenshots and step-by-step instructions).

Question: I've created a form in Access 2007 and I want to have a button on the form that duplicates the current record. What VBA code do I use to duplicate the current record in a form?

Answer: You could create a button on the form and attach the following code to the On_Click event:

Private Sub Command1_Click()

   DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70

End Sub

In this example, we've created a button called Command1. We've placed the above code on the button's click event.