Making "DoCmd.GoToRecord" function work on a subform
As iDevlop noted, you can use the Recordset object of the subform to move to a new record. However, you don't need to create a public sub in the subform. You do it all from the main form:
Me.[subform control name].SetFocus
Form_[subform form name].Recordset.AddNew
In order to use the Form_[form name] syntax, the form has to have a VBA code module. If the form doesn't have one, and for some reason you're opposed to creating an empty one, then you can use the Forms!MyForm.SubformControl.Form syntax instead. But Form_[Form Name] is simpler.
Try placing the code into the subform and then call it from the Parent:
Sub Form Code:
Sub GoToNewRecord()
DoCmd.GoToRecord , , acNewRec
End Sub
Parent Form Code:
Me.sbfrm_subform.GoToNewRecord
Try splitting the operations:
Me.[sbfrm_subform].SetFocus
DoCmd.GoToRecord, , acNewRec
Alternatively, you can try creating a public Sub in the subform, and since it becomes a method of the form you can use that.
Using this on recent versions of Access, you can even try playing directly with the form's recordset instead, like Me.Recordset.Movenext
.
I did the following event procedure in the main form "On Current" :
Private Sub Form_Current()
Me.SubformName.SetFocus
Me.SubformName.Requery
RunCommand acCmdRecordsGoToLast
DoCmd.GoToRecord , , acNewRec
Scan.SetFocus
End Sub
The DoCmd is for the main form to start a new record. Everything before that is to set the subform to the last record AND requery it so that the data is fresh.