Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command button on Main form that starts a new record on sub 1

Status
Not open for further replies.

alanna101207

Technical User
Oct 26, 2007
13
US
I have a main form with a sub form that is set to single form. I have a command button on the main form that I would like to use to start a new record on the sub. I don't want the command button on the subform for appearance reasons. I have tried the following:

DoCmd.GoToRecord , "SubForm", acNewRec

This doesn't seem to work. I also want to set focus on a control on the sub and am not sure on that either.

Any help pointing me in the right direction would be greatful.
 
Me.SubFormNameHere.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Well, I discovered a problem. Here is the code I used:

Me.frm_Daily.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec

It works as far as going to the subform and starting a new record, but the problem is that the main form is also going to a new record.

Not sure if this makes a difference, but the main form is also a subform for the real main form.
 
"the main form is also a subform for the real main form."

huh? I've never done such a thing. explain more.

so this means the "button" is on the sub-sub form (whatever THAT means) as well as the main form, right?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
This form is 3 forms. The Main(1) form has a subform(2). That subForm has it's own subform(3) on it. The command button to start a new record for (3) is on (2).

With the code I showed you I used above, when I click the command button, it starts a new record for (2) and (3). I only want to start a new record for (3). I know the easiest thing would be to just put the command button on (3), but for specific reasons I am trying to keep this command button on (2).

I hope that explains it better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top