You cannot add or change a record because a related record is required in the table

david.paton

Registered User.
Local time
Today, 09:14
Joined
Jun 26, 2013
Messages
338
I have a problem and I can’t seem to work out what is wrong. I am getting the error message You cannot add or change a record because a related record is required in the table ‘Town’.

I am trying to enter new comments on the comments form but whenever I enter all the information and press next, I get the error message “You cannot add or change a record because a related record is required in the table ‘Town’.”

I have been reading forums trying to find something I can try but I just can’t seem to find the answer.

I have attached the database so you can see what I am seeing.

Thanks,
David
 

Attachments

The message is due to Referential Integrity which can be seen in the Relationships window.

It means that the foreign key in the table you are currently entering must already have a corresponding related record in the table on the other side of the relationship.
 
I am not quite sure I completely follow you. There are 2 foreign keys in the table I am entering data, CommentsWidowID and CommentsLegateeID and both of those tables already have data in the table that is linked through the IDs.

By saying it 'must' have a record, do you mean it needs to have a record or it has a record and it shouldn't?
 
Those two tables need to have records matching the IDs currently being entered.
 
It says there is no related record in the table town. I have the widow table being linked to the primary key in the town table using a field in the widow table called WidowTown, which is a number field and has no indexing. It is a one to many relationship with the one on the town ID side.

I looks to me like they have related records in both the widow and town tables. Both tables have data. Do you mean they need to have the same datatype?
 
The WidowTown value in the new record needs to already have a record of the same value in Town.ID.
 

Users who are viewing this thread

Back
Top Bottom