1
votes

How can I reference a button click event on the main form to a subform, similar to:

DoCmd.GoToRecord , , acNewRec

I want to use the subform both for viewing and entering new records but my button is on the main form.

1

1 Answers

1
votes

SetFocus to the subform control, then do GoToRecord.

Private Sub cmdAddSubRow_Click()
    Me.SubControlName.SetFocus
    DoCmd.GoToRecord , , acNewRec
End Sub

Replace SubControlName with the name of the subform control, not the name of the form which is contained in that control. This is an important point which often trips people up.