使用访问权限填充多对多表
我有两个表(persons
和 projects
),它们位于多对多表中,因此由第三个表 persons_projects
链接
在一起我现在创建了一个表单,显示 projects
表中的数据。
我想要的是有一个子表单,显示参与该项目的所有人员数据集。在此子表单中,还应该可以从该项目中添加(或删除)人员 - 下拉列表似乎是此处的最佳选择。
我该怎么做?我可以显示所有参与者,但无法添加他们。似乎我又遇到了“插入视图”问题,因为我需要 persons
和 persons_projects
来显示正确的数据集。但由于我只是在单个表 (persons_projects
) 中更改/添加行,所以我不明白为什么访问再次变得糟糕。
I have two tables (persons
and projects
) which are in a many-to-many table, thus linked together by a third table persons_projects
In ms access I now created a form showing data from the projects
table.
What I want is to have a subform showing all persons
- datasets which participate in this project. In this subform it should also be possible to add (or delete) persons from this project—a drop-down seems the best choice here.
How can I do this? I’m able to show all participants, but I’m not able to add them. seems like I have the “insert into view” problem again, since I need persons
and persons_projects
to show the correct datasets. but as I’m only changing/adding rows in a single table (persons_projects
) I don’t see why access is bitchy again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该需要人员,只需要人员_项目。我假设 person_projects 包含:
和(推荐)日期时间戳和用户字段。
子表单设置有项目 ID 的链接子字段和主字段(将由 Access 自动完成)以及类似于以下内容的组合框:
编辑评论
尽管通常有点困难,但可以包含两个表并具有对于可更新的记录集,查询(视图)应包括连接表中的project_id 和person_id。
You should not need persons, only persons_projects. I assume that persons_projects consists of:
and (recommended) a datetime stamp and user field.
The subform is set-up with a Link Child and Master Field of project_id, which will be automatically completed by Access, and a combobox similar to:
Edit re Comments
It is possible, though often a little more difficult, to include both tables and have an updatable recordset, the query (view) should include both project_id and person_id from the junction table.
听起来人员是这里的驱动数据集,因为您希望能够将其链接到多个项目并删除人员记录。
您的表单基于“人员”表。子表单应基于 person_projects 表并通过相应的 ID 链接。您可以在子表单中的projectid 上使用组合框,并显示一些其他字段,以便用户可以识别项目(名称?)。您可能希望在此表单上显示每个项目的所有项目数据,但您可能会发现它会让用户感到非常困惑。拥有一个可以“弹出”以提供更多项目信息的单独表格可能是更好的选择。
如果你想删除一个人,你可以从persons表中删除,但你需要决定是否想要person_projects表中的任何孤立记录(你不应该这样做)。在 Access 中很容易建立具有引用完整性的链接(级联更新和删除可选)。这需要有多强大取决于您。
Sounds like persons is the driving dataset here since you want to be able to link it to multiple projects as well as delete the person record.
Base your form on the Persons table. A subform should be based on the person_projects table and linked by the corresponding id's. You can use a combo box on the projectid in the subform and have some other field displayed so the user can identify the project (name?). You may want to show all the project data for each project on this form, but you may find it getting very confusing to the user. Having a separate form that you can 'pop-up' to give more project information may be a better choice.
If you want to delete a person, you can just delete from the persons table, but you need to decide if you want any orphan records in the person_projects table (Which you shouldn't). It's easy in Access to establish a link with referencial integrity (cascading update and delete optional). It's up to you as to how robust this needs to be.