Adding record to subform fails

  • Thread starter Thread starter Glenn McIntosh
  • Start date Start date
G

Glenn McIntosh

Hi

I've looked around for this but can't dig up a solution. I have a form
called frmProjectDetails based on a table tblProjectDetails. It
contains a subform called frmPeopleInvolved which writes to a table
called tblPeopleInvolved. The tables are linked 1 to many with
referential integrity set. The tables are linked with autonumber
fields.

The problem is I can't write a record to the subform (which is
embedded in the main form) because a message pops up as soon as i
click back to the main form that says "You cannot add or change a
record as a related record is required in table 'tblPeopleInvolved'.
This makes no sense to me as this is the table that I am actually
entering data into, via the sub form (I though it might be a refernece
to the parent record not being saved yet, but it mentions the wrong
table, plus the parent record IS saved, and not dirty).

I have made all key fields visible and I can see that as I start to
enter a record in the subform the fields are populated with what
appears to be the correct autonumbers to link the child to the parent.
But still the above message pops up when it goes to write the data.

Any idea what I am doing wrong?

Glenn
 
Not to answer your question :-( , but - the relationship between projects &
people is normally many-to-many, not one-to-many. You can't do that with
just 2 tables. You need 3 tables, along the following lines:

tblProjectDetails
ProjectID (PK)
project name, sponsor, etc.

tblPerson
PersonID (PK)
person name, DOB, employee #, etc.

tblProjectPerson
ProjectID ( composite )
PersonID ( primary key )
optional fields for values specific to >this person< on
this project<; perhaps their "role" on the project
(if each person has a single role per project)

HTH,
TC
 
The tables are linked with autonumber fields.

you can't link two tables on autonumber fields (TMK). if the primary key
field of the parent table is being used as the foreign key field in the
child table, then in the child table that field must be set to DataType:
Number, and FieldSize: Long Integer, and Indexed: Yes (Duplicates OK).

hth
 
Hi

I've looked around for this but can't dig up a solution. I have a form
called frmProjectDetails based on a table tblProjectDetails. It
contains a subform called frmPeopleInvolved which writes to a table
called tblPeopleInvolved. The tables are linked 1 to many with
referential integrity set. The tables are linked with autonumber
fields.

The problem is I can't write a record to the subform (which is
embedded in the main form) because a message pops up as soon as i
click back to the main form that says "You cannot add or change a
record as a related record is required in table 'tblPeopleInvolved'.
This makes no sense to me as this is the table that I am actually
entering data into, via the sub form (I though it might be a refernece
to the parent record not being saved yet, but it mentions the wrong
table, plus the parent record IS saved, and not dirty).

I have made all key fields visible and I can see that as I start to
enter a record in the subform the fields are populated with what
appears to be the correct autonumbers to link the child to the parent.
But still the above message pops up when it goes to write the data.

Any idea what I am doing wrong?

Glenn

Just to follow up on this, I have just resolved the issue (took me all
afternoon) and the problem was well and truely of the category of
human error - i.e. me. The error message I was receiving was in fact
referring to a similarly named table (that I mistook for the subform's
table, and that really has little to do with anything). I later found
a dubious link in the relationships diagram that was forcing, be
referential integrity I suppose, a value to appear in this other
table. Removing the link made the message go away.

Thanks - and apologies - to Tina and TC for their input on this, which
was insightful for other reasons! I can add that I was using a non
autonumber in the child table that links back to the parent.

Glenn
 
Back
Top