I have a series of forms and on each one I would like to add a Back button, so I created a command button and to the on click event assigned it trigger the following VBA;
Private Sub cmdBack_Click()
On Error GoTo Err_CmdBack_Click
If Me.Dirty Then Me.Dirty = False
DoCmd.Close
Exit_CmdBack_Click:
Exit Sub
Err_CmdBack_Click:
MsgBox Err.Description
Resume Exit_CmdBack_Click
End Sub
How can I now, or what is the best way, to copy this button to all the other forms with the code? If I just copy and paste I lose the code and I don't want to re-write the code for each button that seems inefficient.