title: Dynamically activate "OnClick" function in command button in a subform in access 2007
body: <p>I've created a form with 3 subforms in it to display an user's details and the inventory the user has. The form enables user to update the details displayed. Thus each subform has a "save" and "undo" button. I'm trying to create a "Clear All" button on the parent form which undo all changes there are in all the 3 subforms.</p>
  
  <p>I don't really want to retype the same codes used in the 3 "undo" buttons, so is there a way to make use of the Onclick function of the 3 buttons? </p>
  
  <p>I've tried the following with one subform first:</p>
  
  <pre><code>Private Sub ClearAllParentForm_Click()
      Me.Subform1.Form.clearButton_Click
  End Sub
  </code></pre>
  
  <p>However, the form invokes the subform's beforeupdate event instead (a messagebox that prompts user to save the updated record). I've also tried to change the codes to Me.Subform1.Form.Undo which produces the same issue. Is there somewhere which I did wrongly or is my concept wrong?</p>
  
  <p>Sorry, just started using Microsoft Access 2007 only recently so quite confused with some stuff.</p>