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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing Parent Form's primary key from Subform

Status
Not open for further replies.

roarlad

Programmer
Jun 8, 2007
5
IE
Hi,
sorry but I'm still teaching myself Access so the answer to this question may be easy or the question mightn't make sense. But I'm not in a rush so I've time to explain or give details:

I have a main form called UserFrm which creates records, each record created uses a primary key called EE_ID (which is an autonumber)
and then i have a subform called SectionTab which updates a table called tblUserSections.
What I need to do is get the EE_ID from the UserFrm and pass this value into the tblUserSections table. I don't need control of the EE_ID just want to reference it.
Should I use a get the recordset of the parent form? and if so how do I use the EE_ID value if the record hasn't been created yet? should I update the tblUserSections table
from the UserFrm and if so how?

thanks in advance.
 
Why aren't the forms linked by EE_ID ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
they are, I think.
the subform (SectionTab)
has property
Link Child Fields: EE_ID
Link Master Fields: EE_ID

Is this what you are talking about?
I know that I can change the Subform's Record Source to that of the table that holds the EE_ID. so I know how to control the EE_ID, I also know I could build an expession to get a read only of the EE_ID. although I tried this and got #Name? so the sytax is wrong somewhere.
but what I need to do is code to get the EE_ID and pass the information on to update the table in the subform OR
update the subform's table from the parent form.
thanks.
 
roarlad said:
OR
update the subform's table from the parent form
As PHV has already hinted, if you the subform is properly linked to the main form through the EE_ID field, Access will do this automatically for you. You don't have to write any code to look up the main record's ID, it will be inserted automatically into the child record.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top