You have some great answers here.
However, your question remains un-answered.
How are these column values set? What is the mechanical process as you ask!
How do you set this column value to relate back to the parent table?
It turns out that if you create a form based on this child table, when you add a record, then YOU must MANUALLY enter the value of that column used to relate back to the parent
table. Or you can write some code to do this for you!
In other words, when you add a record in a form, you THEN must type in the value for this column used to relate back to the parent record. Or as noted, have soe code set this value.
Another way (recommended way) is to build a form with a sub form. When you use a sub-form, then for each child record you add, the FK (foreign key) value can be (will be) set for
you automatically by Access.
And if you have a main form, and you have say a button on the form to launch a form based on the child table, then you will have to PASS the primary key value from that form. Or
have the form look back to the other form.
So YOU will write code in the form based on this table of child records to correctly SET the FK value column to relate back to the one parent record in the parent table.
So the confusing part here is that when you setup a relationships, this “act” of setting up a relationship does NOT relieve you of the responsibility to setup and maintain that
relationships with your code, or as noted letting Access set this FK value by using a form + sub-form arrangement.
So the FK column is in general a plane Jane long number type of column. This long number column thus must have a value set that points back to the parent record (the value you enter
into this editable columns is the PK auto number ID of the parent record you wish to relate to).
And MOST important is then your code, your form etc. MUST set this value to attach the record to the parent record. In other words, either your code or your user will have to choose
and type in this value.
So the “mystery” part here is that Access will NOT set the value of this column used to relate back to the parent record. (exception being a form + subform)
The above thus quite much suggest that YOU have to “choose” the parent record PK value to set – Access will not do this for you automatically, the exception being when you use a
form + sub form. In the form + sub form setup, access can set the FK value by looking at the PK value currently set in the parent form.
The mechanical process:
In a form + sub-form, this setting is called the link master and link child settings. Once you set this, then for each child record you add, the parent record pk ID value will be
pulled and placed into the FK. You can see/view this setting by clicking on a sub form control, and viewing properties.
If the two forms are separate, then in the second forms on-insert event, you can set the FK id in code like this
Me.tblecust_ID = forms!EditCustorm!id
Of course the above is for child records. For tables that drive a user set of choices, then a combo box is most often how users select such values.
Regards,
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada