Access won't accept records entered in my sub-form

G

Guest

I have designed a form that displays the information from the parent table at
the top and displays the information from the child table in a subform
displayed in datasheet view. The parent and child table have a one to many
relationship. The table that the subform is linked to is void of records at
present. When I attempt to enter a record through the subform I receive and
error message that reads, "You cannot add or change a record because a
related record is required in the parent table." Also, the PK in the parent
table does not record in the FK of the child table it is linked to (some
times the name of the form loads in this field instead of the PK).
 
G

Graham Mandeno

Hi Lorraine

It sounds like your main form and subform are not properly linked.

Check the property sheet for the subform control. It should have:

LinkMasterFields: <name of the PK in your parent table>
LinkChildFields: <name of the FK in your related table>
 
G

Guest

Graham,

The subform control does not have properties named MasterFields and
ChildFields.
--
Lorraine


Graham Mandeno said:
Hi Lorraine

It sounds like your main form and subform are not properly linked.

Check the property sheet for the subform control. It should have:

LinkMasterFields: <name of the PK in your parent table>
LinkChildFields: <name of the FK in your related table>
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Lorraine said:
I have designed a form that displays the information from the parent table
at
the top and displays the information from the child table in a subform
displayed in datasheet view. The parent and child table have a one to
many
relationship. The table that the subform is linked to is void of records
at
present. When I attempt to enter a record through the subform I receive
and
error message that reads, "You cannot add or change a record because a
related record is required in the parent table." Also, the PK in the
parent
table does not record in the FK of the child table it is linked to (some
times the name of the form loads in this field instead of the PK).
 
G

Graham Mandeno

Hi Lorraine

First, are you sure you have selected the subform *control* and not some
object on the subform?

The title of the properties window should say "Subform/Subreport: <name of
control>"

Selecting it can sometimes be a little tricky. Click on some control
outside your subform to select that first, then click *once* on the subform.
It's usually best to click on the very border of the subform to get the
container control.

Once you have it, with the "All" tab selected, the properties third and
fourth from the top should be "Link Child Fields" and "Link Master Fields".
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Lorraine said:
Graham,

The subform control does not have properties named MasterFields and
ChildFields.
--
Lorraine


Graham Mandeno said:
Hi Lorraine

It sounds like your main form and subform are not properly linked.

Check the property sheet for the subform control. It should have:

LinkMasterFields: <name of the PK in your parent table>
LinkChildFields: <name of the FK in your related table>
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Lorraine said:
I have designed a form that displays the information from the parent
table
at
the top and displays the information from the child table in a subform
displayed in datasheet view. The parent and child table have a one to
many
relationship. The table that the subform is linked to is void of
records
at
present. When I attempt to enter a record through the subform I
receive
and
error message that reads, "You cannot add or change a record because a
related record is required in the parent table." Also, the PK in the
parent
table does not record in the FK of the child table it is linked to
(some
times the name of the form loads in this field instead of the PK).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top