[英]MS ACCESS: Populate a subform with data from another table
I have three tables in my Access Database. 我的Access数据库中有三个表。
**Table: Participants**
ParticipantID
FirstName
LastName
Address
Phone
SiteNameLookup
YearLookup
**Table: DailyWorkshops**
WkshpID
WkshpDate
AorB
SiteStaff
Artists
Activities
**Table: ParticipantAttendance**
ParticipantID Participants.ParticipantID
FirstName Participants.FirstName
LastName Participants.LastName
WkshpID DailyWorkshops.WkshpID
Level *(here I have a lookup to fill in HALF/PARTIAL/FULL, not just yes/no)*
I have succesfully created a form, DailyWorkshopsForm, that has a subform of ParticipantAttendance. 我已经成功创建了一个表单DailyWorkshopsForm,该表单具有ParticipantAttendance的子表单。 This subform is completely blank.
此子窗体是完全空白。
How can I now populate the ParticipantAttendance subform from the Participants form so all I have to do is check off the attendance level for each participant? 现在如何从“参与者”表单填充“参与者参与”子表单,所以我要做的就是核对每个参与者的出勤水平? I can figure out how to look up just Participant.ParticipantID or just Participant.FirstName or just Participant.LastName --- but looking up one doesn't automatically fill in the others... so I could end up looking up an ID # but not get the name that goes with it.
我可以弄清楚如何仅查找Participant.ParticipantID或Participant.FirstName或Participant.LastName ---但查找一个并不会自动填写其他...因此我最终只能查找ID#但没有得到与其搭配的名称。
Edit: Clarification of question & problem. 编辑:澄清问题。
Thanks... as I look at it more I realize ParticipantAttendance is not what the subform should be... that's just the table where the attendance data should ultimately live. 谢谢...随着我对它的了解越来越多,我意识到ParticipantAttendance不是该子表单应该的内容...那只是出席数据最终应该存在的表格。 What I need for the subform is something that looks like this:
我需要的子表单如下所示:
WkshpID ParticipantID FirstName Lastname Level
6 10-45 Bart Simpson Full
6 10-47 Ned Flanders Half
6 10-49 George Washington None
6 10-50 Michelle Obama Full
7 10-45 Bart Simpson Full
7 10-47 Ned Flanders Full
7 10-49 George Washington Half
7 10-50 Michelle Obama None
8 10-45 Bart Simpson Full
8 10-47 Ned Flanders None
8 10-49 George Washington Half
8 10-50 Michelle Obama Half`
If you look to the properties of the subform, you'll see that there is a way to indicate a "foreign key" relation between the parent form and the subform (look at the "Data", "Link Master Fields" to "Link Child Fields"). 如果查看子表单的属性,您会发现有一种方法可以指示父表单和子表单之间的“外键”关系(请查看“数据”,“链接主字段”到“链接”子字段”)。 In your case you need to link the field WkshpID of both tables.
在您的情况下,您需要链接两个表的WkshpID字段。
Then just use a normal SQL query as SELECT * FROM ParticipantAttendance
in your subform, the WHERE condition will be automatically imposed by MS Access using the foreign key relation from the parent form and duly updated as long as you navigate to other data row in your parent form. 然后,只需在子窗体中使用普通的SQL查询作为
SELECT * FROM ParticipantAttendance
,WHERE条件将由MS Access使用父窗体中的外键关系自动强加,并且只要您导航到父窗体中的其他数据行就可以适当更新形成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.