user1868306
user1868306

Reputation: 75

Activate subform for data entry using a button on main form

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.

Upvotes: 1

Views: 2549

Answers (1)

HansUp
HansUp

Reputation: 97101

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.

Upvotes: 1

Related Questions