Opening subform to a new record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform which I would like to open to a new record when the main form opens.
I put a macro on the On Enter property of the subform that tells it to open the subform to a new record, but when I did this is told me that I was trying to open a record in a form that wasn't open... so... I put an open form in the macro.
This opened the subform ONLY (not within the form) which is not my intent.
How do I get the form to open, with the subform included, and have the subform open to a new record?
I must be close?? I've referenced all my books and help, and I'm just not hitting on the right combination. HELP!!
 
A subform is not open by itself - it is only open indirectly through the
subform control on the main form. Let's say your subform control is
'sfrmSub1' - Note that this is not necessarily the same as the name of the
form object that is referenced in the ControlSource of the subform control.
To be sure, open the main form and click once on the subform then check the
name property under the Other tab. Whatever you find there is what belongs
in place of sfrmSub1.

Now to get to a new record on the subform you must first set focus to the
subform control itself:

me.sfrmSub1.setfocus

Then you can issue the command to go to a new record:

DoCmd.GoToRecord , , acNewRec
 
Thank you soooo much! I'm not really adept at code yet, but I'm learning. I did what you had suggested, and it worked. And what's better... I even understand what I did and why I did it! I know code is much better than macros, but I have a long learning curve ahead of me. Thanks again!!!!!
 
Back
Top