Error "you cannot add or change a record because a related record is required in table exp_main"

Error "you cannot add or change a record because a related record is required in table exp_main"

I am getting the above error message on my database:

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

I have a table called exp_mian and a various other table called employee_cost_details, project_cost_details etc which are linked with exp_main. One exp_main(exp_id) record will be linked to the previously mentioned tables record. However, one employee_cost_details table record will be linked to exactly one exp_main record. I also have a main form for the exp_main data that contains a subform for entering the details of the other tables data. When I try to add a new record to the employee_cost_details table, I get the above error message.  Any ideas?
i will attach the sample relationships with the question.

kindly help me out with this problem.

Thanks!
relationships.bmp
IT235Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
peter57rConnect With a Mentor Commented:
Looking at your diagram, you have defined the relationships such that you must have a record set up in emp-gen-details and in exp-main before you can enter a matching record in emp-cost details.  Looking at the field lists, that would seem quite appropriate.

And that is what the message is telling you.  
If you think you have the prerequisite records saved before trying to create a emp-cost-details record then you perhaps need to check the master/child links on the subform.  Also, assuming that in the subform you are using a combo box to select the emp-gen-details key then you need to be sure the correct (id ) column is the bound column.
0
 
IT235Author Commented:
First of all thank you for the solution.
But as you can see from the relationship diagram that there are related fields between the emp_gen_details and emp_cost_details i.e emp_id AND the related fields between emp_cost_details and exp_main is exp_id.
so first of all the general details are saved in the emp_general_details table and then if any expense comes then first of all the common details of expense bill are stored and then according to the expenditure on option in the exp_main table, the next related table opens and the further details are stored, so for that purpose the is exp_id the common field between the table.

so can you look in the matter and let me know were i m going wrong.

Thanks!
0
 
IT235Author Commented:
First of all thank you for the solution.
But as you can see from the relationship diagram that there are related fields between the emp_gen_details and emp_cost_details i.e emp_id AND the related fields between emp_cost_details and exp_main is exp_id.
so first of all the general details are saved in the emp_general_details table and then if any expense comes then first of all the common details of expense bill are stored and then according to the expenditure on option in the exp_main table, the next related table opens and the further details are stored, so for that purpose the is exp_id the common field between the table.

so can you look in the matter and let me know were i m going wrong.

Thanks!
0
 
peter57rCommented:
First - you should not accept an answer until your Q is resolved (or cannot be resolved) - many 'experts' will never return to Q's once they see an 'Accept' .

If you are saying that your current data entry sequence in your data entry form(s) is..
1 emp-gen-details
2 exp_main
3 emp-cost details
then in theory you should not have the problem you posted.

If you still have this problem, then there must be a problem with the structure of your data entry form(s).

As I said before, this could be in the way the main/subform links have been defined or in the way the key fields are being assigned in the subform

If you still have the problem, then it would be better to post a sample db which shows the problem ,  as trying to use words to describe all this could get very confusing.







0
All Courses

From novice to tech pro — start learning today.