add new record on subform from main form buttom

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
 
T

tina

try

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

hth
 
M

msmuzila

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.
 
M

msmuzila

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top