如何创建将数据放入两个表中的数据输入表单
我有学生
和课程
表,
Student
--------
ID - Primary Key - AutoNumber
Name - Text
Age - Number
Courses
-------
CID - Foreign Key
CourseTitle - Text
学生表中的ID
链接到课程
问题CID strong>
我想创建一个简单的数据输入表单,用于收集学生姓名
、年龄
和课程标题
。姓名和年龄应位于 Student
表中,但是课程标题应位于 Course
表中。
我该怎么做?我知道如何创建一个将数据放入一个表中的数据输入表单,但不知道如何在维护关系的同时将其放入两个表中。我真的很感激屏幕截图。
I have Student
and Course
Tables
Student
--------
ID - Primary Key - AutoNumber
Name - Text
Age - Number
Courses
-------
CID - Foreign Key
CourseTitle - Text
ID
in Student table is linked to CID
in Courses
Question
I want to create a simple Data Entry form that collects a Students Name
, Age
and Course Title
. The Name and Age should go in Student
table however, the Course Title should go in Course
table.
How do I do this? I know how to create a data entry form that puts data in one table but don't know how to put it in two tables while maintaining the relationship. I would really appreciate a screenshot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设每个学生可以有 0 到多门课程,您应该在数据输入表单上创建一个子表单,并列出每个学生的课程。
听起来您正在使用 Access Forms 设计器(而不是 VBA 代码)执行此操作:
将此表单的数据源设置为您的学生表,然后添加要显示的字段(您可以从“可用字段”菜单中拖动这些字段。
创建另一个名为 sfmCourses 的表单,并将数据源设置为您的课程表。将此表单的默认视图设置为连续表单或数据表。在设计视图中,您仍然会看到标准表单设计器视图。将您想要使用的字段拖放到表单上并进行排列以适合。
向 frmStudents 添加一个子表单容器,并将 SourceObject 属性设置为 sfmCourses。然后使用 LinkMasterFields 属性建立两者之间的关系。
希望有帮助。
Assuming that each student can have 0 to many courses, you should create a subform on your data entry form with the courses for each student listed.
It sounds like you are doing this using the Access Forms designer (as opposed to VBA code):
Set the datasource for this form to your students table, and then add the fields you want displayed (You can drag these from the "available fields) menu.
Create another form named sfmCourses and set the datasource to your courses table. Set the default view for this form to either continuaous forms or Datasheet. While in design view you will still see a standard forms designer view. Drag and drop the fields you want available onto the form and arrange to suit.
Add a Subform container to frmStudents and set the SourceObject property to sfmCourses. Then use the LinkMasterFields property to establish the relationship between the two.
Hope that helps.