Create a new record in subform (1 Viewer)

X@1

New member
Local time
Today, 01:30
Joined
May 3, 2019
Messages
3
I have a button on a form that opens a second that contains a (referenced) subform. I want to create a new record in this subform where I will insert the related fields. I am having difficulty opening this new record in the subform. I open the parent form, focus the subform, ...

* Form1(Father) SubForm1(son) *
* master field=[Form1].[Id] *
* son field=[SubForm1].Form![Idd] *

...
In the Form0, button:
DoCmd.OpenForm "Form1"

...

In the Form1('open' event)

Forms![Form1]![SubForm1].setfocus
DoCmd.GoToRecord , , acNewRec
Forms![Form1]![SubForm1].Form![Idd]= Forms![Form1].[Id]

I am not able to create a new record in SubForm1, thank you to anyone who can help.
 

June7

AWF VIP
Local time
Today, 00:30
Joined
Mar 9, 2014
Messages
5,492
Main form and subform have linked data? Should not need code to pass the ID from Form1 to its subform. If Master/Child Link properties are set, the ID should pass automatically as soon as any other data is input. This is the reason for form/subform structure - to facilitate records association.
 

jdraw

Super Moderator
Staff member
Local time
Today, 04:30
Joined
Jan 23, 2006
Messages
15,394
Further to June' advice - on the main form (Father) and the subform (Son) I would expect the FatheriD on subform to be matched with FatherID on mainform. The sonID on subform would idenftify the person/son on subform, but you need the FatherID on subform to show "whose son this is".
If we have misunderstood the requirement, then please provide example and clear description.
Good luck.
 

Users who are viewing this thread

Top Bottom