具有多对多关系的数据输入表单 [英] Data Entry Form with a Many-to-Many Relationship

查看:32
本文介绍了具有多对多关系的数据输入表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我使用Access 2007启动一个小型家庭图书馆应用程序,到目前为止它有两个表格。

1.书籍,包含字段Book_ID(主键)和标题,以及

2.作者,包含字段Author_ID(主键),First_Name和Last_Name。


我解决了当前的问题之后,这两个表格都会被扩展


因为一本书可以有多个作者,并且因为一个作者可以有几本书,我想使用多对多的关系。为此,我创建了一个名为Books_Authors的第三个表(一个联结表??),其中包含字段Book_ID和Author_ID。然后,我在Book_ID字段上创建了Books和Books_Authors之间的一对多关系,并且与Authors表类似。据我所知,现在应该给我两个主要表格,书籍和作者之间的多对多关系。


现在出现了问题。我想基于Books表创建一个数据输入表单,但是我允许我为每个书名输入一个或多个作者。我尝试使用带有子表单的表单,这似乎达到了一定程度。它恰当地填充了两个主表,即Books表包含书名列表,Authors表包含作者列表。但是联结表是空的! (并且可能这意味着多对多关系不起作用。)


我在尝试输入数据时收到错误消息(字段无法更新)作者子目录中的字段


如果对此有任何帮助,我将不胜感激。


提前致谢


Robert

Hi all

I am using Access 2007 to start a small home library application, and so far it has two tables.
1. Books, with fields Book_ID (Primary Key) and Title, and
2. Authors, with fields Author_ID (Primary Key), First_Name and Last_Name.

Both tables will be expanded later, after I have solved my current problem

Because one book can have multiple authors, and because one author can have several books, I want to use a many-to-many relationship. To do this I created a third table (a junction table??) called Books_Authors, with fields Book_ID and Author_ID. I then created a One-to-Many relationship between Books and Books_Authors on the Book_ID fields, and similarly with the Authors table. As I understand it that should now give me a Many-to-Many relationship between my two main tables, Books and Authors.

Now comes the problem. I want to create a form for data entry, based on the Books table, but which allows me to enter one or more Authors for each book title. I tried using a form with a subform, and this seemed to work up to a point. It filled the two main tables appropriately, ie the Books table contained a list of book titles, and the Authors table contained a list of authors. But the junction table was empty! (and presumably this means that the Many-to-Many relationship is just not working.)

I received an error message (Field cannot be updated) when I tried to enter data into the fields in the Authors subform

I would be grateful for any assistance with this.

Thanks in advance

Robert

推荐答案


大家好


我是使用Access 2007启动一个小型的家庭图书馆应用程序,到目前为止它有两个表格。

1.书籍,包含字段Book_ID(主键)和标题,以及

2.作者,字段为Author_ID(主键),First_Name和Last_Name。


我解决了当前的问题之后,这两个表格都会被扩展


因为一本书可以有多个作者,并且因为一个作者可以有几本书,我想使用多对多的关系。为此,我创建了一个名为Books_Authors的第三个表(一个联结表??),其中包含字段Book_ID和Author_ID。然后,我在Book_ID字段上创建了Books和Books_Authors之间的一对多关系,并且与Authors表类似。据我所知,现在应该给我两个主要表格,书籍和作者之间的多对多关系。


现在出现了问题。我想基于Books表创建一个数据输入表单,但是我允许我为每个书名输入一个或多个作者。我尝试使用带有子表单的表单,这似乎达到了一定程度。它恰当地填充了两个主表,即Books表包含书名列表,Authors表包含作者列表。但是联结表是空的! (并且可能这意味着多对多关系不起作用。)


我在尝试输入数据时收到错误消息(字段无法更新)作者子目录中的字段


如果对此有任何帮助,我将不胜感激。


提前致谢


Robert
Hi all

I am using Access 2007 to start a small home library application, and so far it has two tables.
1. Books, with fields Book_ID (Primary Key) and Title, and
2. Authors, with fields Author_ID (Primary Key), First_Name and Last_Name.

Both tables will be expanded later, after I have solved my current problem

Because one book can have multiple authors, and because one author can have several books, I want to use a many-to-many relationship. To do this I created a third table (a junction table??) called Books_Authors, with fields Book_ID and Author_ID. I then created a One-to-Many relationship between Books and Books_Authors on the Book_ID fields, and similarly with the Authors table. As I understand it that should now give me a Many-to-Many relationship between my two main tables, Books and Authors.

Now comes the problem. I want to create a form for data entry, based on the Books table, but which allows me to enter one or more Authors for each book title. I tried using a form with a subform, and this seemed to work up to a point. It filled the two main tables appropriately, ie the Books table contained a list of book titles, and the Authors table contained a list of authors. But the junction table was empty! (and presumably this means that the Many-to-Many relationship is just not working.)

I received an error message (Field cannot be updated) when I tried to enter data into the fields in the Authors subform

I would be grateful for any assistance with this.

Thanks in advance

Robert



我刚刚创建了一个模板,用于几乎与您目前处于完全相同状态的人,以及为实现逻辑而苦苦挣扎的人。这个简单的数据库由2个表组成,这些表通常包含许多到多个关系(PC到软件),由中间表连接,创建了2到1到多个关系。他还想知道如何在这个设计下添加各种软件包,这与你想要完成的事情有着惊人的比较。不要试图详细解释在现有结构下添加记录所需的步骤,只需简单下载数据库,如果您有任何问题,请随时询问。

I just created a Template for someone who had almost the exact same situation that you are currently in, and who struggled with implementing the logic. This simple Database consists of 2 Tables which would normally comprise a MANY to MANY Relationship (PCs to Software), joined by an Intermediate Table which created 2 - 1 to MANY Relationships. He also wanted to know how he could add various Software Packages under this design which has an uncanny comparison to what you are trying to accomplish. Rather than trying to explain in detail the steps necessary to Add Records under this existing structure, simple download the Database and should you have any questions, feel free to ask.



我刚刚创建了一个模板,用于那些几乎与你目前处于完全相同状态的人,并且他们正在努力实现逻辑。这个简单的数据库由2个表组成,这些表通常包含许多到多个关系(PC到软件),由中间表连接,创建了2到1到多个关系。他还想知道如何在这个设计下添加各种软件包,这与你想要完成的事情有着惊人的比较。而不是试图详细解释在现有结构下添加记录所需的步骤,只需简单下载数据库,如果您有任何问题,请随时提出。
I just created a Template for someone who had almost the exact same situation that you are currently in, and who struggled with implementing the logic. This simple Database consists of 2 Tables which would normally comprise a MANY to MANY Relationship (PCs to Software), joined by an Intermediate Table which created 2 - 1 to MANY Relationships. He also wanted to know how he could add various Software Packages under this design which has an uncanny comparison to what you are trying to accomplish. Rather than trying to explain in detail the steps necessary to Add Records under this existing structure, simple download the Database and should you have any questions, feel free to ask.



谢谢,ADezii


这对我来说非常有帮助。我现在正在努力弄清楚为什么我要做的事情,看起来与你的解决方案非常相似,不起作用。我假设使用PC-Software模板,在尝试使用PC表格之前必须填充Software表,即Software表然后用作Lookup表。我想要的是能够将我的作者输入到书籍表格的子表格中。换句话说,我想打开主窗体,输入Book详细信息,然后转到Authors子窗体,我可以从作者列表中选择(来自Authors表)或直接添加新作者(可能是使用组合框)。


也许最简单的方法是复制模型,即使用下拉列表选择作者,如果是新作者,则构建一个按钮,我可以在Authors表格的另一个参赛表格中添加新作者,然后返回原始表格/子表格并使用下拉列表,该列表现在应该包括新作者。


希望这是有道理的。如果我不能上班,我会回复你的建议。


再次感谢。


Robert

Thanks, ADezii

This is very helpful for me as a learning exercise. I am presently trying to work out why what I was trying to do, which looked very similar to your solution, doesn''t work. I presume that with the PC-Software template it is necessary to populate the Software table before trying to use the PC form, ie the Software table is then used as a Lookup table. What I was wanting was to be able to enter my Authors onto the subform of the Books form. In other words, I wanted to open the main form, enter the Book details, and then move to the Authors subform where I could either select from the list of authors (from the Authors table) or add a new Author directly (presumably using a combo box).

Perhaps the easiest way will be for me to copy your model, ie using the drop-down list to select an author and, if it a new author, build in a button which takes me to another entry form just for the Authors table where I can add the new author and then return to the original form/subform and use the dropdown list which should now include the new author.

Hope this makes sense. If I can''t get it to work I''ll come back to you for advice.

Thanks again.

Robert



谢谢,ADezii


这对我来说非常有用。我现在正在努力弄清楚为什么我要做的事情,看起来与你的解决方案非常相似,不起作用。我假设使用PC-Software模板,在尝试使用PC表格之前必须填充Software表,即Software表然后用作Lookup表。我想要的是能够将我的作者输入到书籍表格的子表格中。换句话说,我想打开主窗体,输入Book详细信息,然后转到Authors子窗体,我可以从作者列表中选择(来自Authors表)或直接添加新作者(可能是使用组合框)。


也许最简单的方法是复制模型,即使用下拉列表选择作者,如果是新作者,则构建一个按钮,我可以在Authors表格的另一个参赛表格中添加新作者,然后返回原始表格/子表格并使用下拉列表,该列表现在应该包括新作者。


希望这是有道理的。如果我不能上班,我会回复你的建议。


再次感谢。


Robert
Thanks, ADezii

This is very helpful for me as a learning exercise. I am presently trying to work out why what I was trying to do, which looked very similar to your solution, doesn''t work. I presume that with the PC-Software template it is necessary to populate the Software table before trying to use the PC form, ie the Software table is then used as a Lookup table. What I was wanting was to be able to enter my Authors onto the subform of the Books form. In other words, I wanted to open the main form, enter the Book details, and then move to the Authors subform where I could either select from the list of authors (from the Authors table) or add a new Author directly (presumably using a combo box).

Perhaps the easiest way will be for me to copy your model, ie using the drop-down list to select an author and, if it a new author, build in a button which takes me to another entry form just for the Authors table where I can add the new author and then return to the original form/subform and use the dropdown list which should now include the new author.

Hope this makes sense. If I can''t get it to work I''ll come back to you for advice.

Thanks again.

Robert



你好罗伯特。我应该修改我的模板以满足您的特定需求,然后将其作为附件提供给您。我不能给你一个特定的时间来完成这项工作,但如果这个项目没有大力推动,我将非常乐意接待你。

Hello Robert. What I''ll due is to modify my Template to suit your specific needs, then make it available to you an as Attachment. I cannot give you a specific time when this will be done, but if there is no great rush on this Project, I''ll be more than happy to accommodate you.


这篇关于具有多对多关系的数据输入表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆