add new record on subform from main form buttom

  • Thread starter Thread starter msmuzila
  • Start date Start date
M

msmuzila

how do i incorporate

DoCmd.GoToRecord , , acNewRec

into a main forms button to go to a subforms new record.

When i press the button, i want the subform to go to a new record
 
try

Me!NameOfSubformControl.SetFocus
Me!NameOfSubformControl!NameOfAControlOnSubform.SetFocus
With Me!NameOfSubformControl.Form
DoCmd.RunCommand acCmdRecordsGoToNew
End With

hth
 
how would I modify this to only add new if there is at least one record
in the record set. I dont want to add new if their is no records, i
just want to set focus.
 
I got it, if you change the command line to the following (4th line):

Me!NameOfSubformControl.SetFocus
Me!NameOfSubformControl!NameOfAControlOnSubform.SetFocus
With Me!NameOfSubform.Form
DoCmd.GoToRecord , , acNewRec
End With
 
Back
Top