Error: ou cannot add or change a record because a related record is required in table

Zak14

Registered User.
Local time
Today, 11:46
Joined
Jun 27, 2014
Messages
166
My form is made up of multiple tables that have a 1-to-1 relationship. It also has a subform which is a 1-to-many relationship.

Adding a record from the form by filling in fields only from the main table works fine, but, if I fill in a field from another table, it sometimes works and sometimes doesn't.
It displays a message:
Code:
You cannot add or change a record because a related record is required in table "tbl_Details"
I've designed a sample DB with the same settings and layout and all and attached it here because I can't upload the original. Plus it will be easier to understand.

NOTE: I've just looked at the db I uploaded and it seems like the records have mixed up now.
Like, the address for record 6 is now assigned to record 3.
And it doesn't show record 1 or 2
What's going on.
 

Attachments

Last edited:
The issue of course is your relationships. Correct this and the problem will go away!
 
What's wrong with my relationships
 
I did not download you db but can you post a screenshot of your relationships?
 
Here it is.
 

Attachments

  • Capture.PNG
    Capture.PNG
    39.3 KB · Views: 300
Zak,

Can a Person have more than 1 address?
Can a Person have more than 1 phone?
Can a Person have more than 1 email?
 
Zak,

Can a Person have more than 1 address?
Can a Person have more than 1 phone?
Can a Person have more than 1 email?

1 address, 1 email, Multiple phones.
The phones are in a subform and the other 2 aren't because they are 1-to-1.
Even if I remove the subform, the problem persists, so the problem isn't there.
 
For the 1-1s, why not include those fields in your Details table, and why not rename the Details to PersonDetails?
 
For the 1-1s, why not include those fields in your Details table, and why not rename the Details to PersonDetails?

I done it like this because I want to separate unrelated fields.
The naming isn't the naming on my actual form; there's a whole lot more in my actual form.

It seems to work better if I edit the relationship to cascade update and delete but I don't want that.
Either way, I can't move to the next record without having a PrimaryKey specified for the main table. I want to be able to continue whether a primary key (ID) is defined or not.

I know it should work like this, as I have a similar database to this that works fine.
 
You cannot relate Autonumber to Autonumber only Autonumber to Number (Long). Fix that and you should be fine.

Oh, and your error message is because tbl_Details (Autonumber) is related to tbl_DetailsPhone (Autonumber). Well, Autonumber can only count it cannot inherit the Autonumber from tbl_Details.
 

Users who are viewing this thread

Back
Top Bottom