不允许在MS Access中创建或更改记录 [英] Not allowed to create or change a record in MS Access
问题描述
我已经阅读了有关上述问题的大量主题,但是没有一个答案可以解决这个问题.我的问题是使用"ID"字段(也是主键)将两个表彼此链接(以一对一关系).当我尝试在主表中输入一条记录(不知道Access是否知道这是主表)时,出现以下错误:
I have read numerous thread on the above question, but none of the answers satisfy the problem. My problem is two tables that are linked to each other (in a one to one relationship) using an "ID" field which is also the primary key. When I try to enter a record in the the main table (Don't know if Access knows this is the main table) the I get the following error:
"You cannot add or change a record because a related record is required in table"
有人可以帮我吗?
谢谢
推荐答案
该问题似乎正在发生,因为您试图将表的主键设置为外部表.
The issue seems to be occuring because you are trying to set the primary key of your table as a foreign table.
您需要做的是在第二个表中创建一个新列,并将其链接到第一个表的ID,从而创建一个关系.
What you need to do is create a new column in the 2nd table and link it to the id of the first table, therefore creating a relationship.
让我们举一个简单的例子,因为您没有提到为表指定的名称.
Let's take the following simple example since you haven't mentioned the names given to your tables.
在大学环境中,您将拥有LECTURER表,该表链接到SUBJECT表,以便讲师可以教授主题.这两个表之间的关系应为:
In a university environment, you would have the table LECTURER which is linked to the table SUBJECT, so that a lecturer can teach a subject. The relationship between the 2 tables would be so:
讲台
LECTURER_ID | LECTURER_NAME | LECTURER_ADDRESS
LECTURER_ID | LECTURER_NAME | LECTURER_ADDRESS
主题表
SUBJECT_ID | SUBJECT_NAME | SUBJECT_DESCRIPTION | SUBJECT_LECTURER_ID
SUBJECT_ID | SUBJECT_NAME | SUBJECT_DESCRIPTION | SUBJECT_LECTURER_ID
这两个表之间的链接将位于SUBJECT表中的SUBJECT_LECTURER_ID和LECTURER表中的LECTURER_ID之间.这是一对一的关系,因为我们假设该特定大学中的每个科目仅由一名讲师讲授,而一名讲师只能教一个单一科目.
The link between these two tables would be between the SUBJECT_LECTURER_ID from the SUBJECT table and the LECTURER_ID from the LECTURER table. This is a one to one relationship since we are assuming that each subject in this particular university is only taught by one lecturer, and a lecturer can only teach one single subject.
希望这会有所帮助:)
这篇关于不允许在MS Access中创建或更改记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!