简体   繁体   English

SubForm排除Microsoft Access

[英]SubForm exclusions Microsoft Access

I have a practice database I'm developing in order to become familiar with access. 我有一个正在开发的练习数据库,以便熟悉访问。 I have created 3 tables, Employees, Computers and Warranty. 我创建了3个表,雇员,计算机和保修。 In the Employee Table there is an Eid (PK), First Name, Last Name and Location. 在员工表中有一个Eid(PK),名字,姓氏和位置。 In the computer table there is an Eid(FK), Serial Number (PK) and various identifiers such as brand, size,etc. 在计算机表中有一个Eid(FK),序列号(PK)和各种标识符,例如品牌,尺寸等。

Problem I want the form to show only the employees who currently have a device followed by the devices they have displayed in a subform. 问题我希望表单仅显示当前拥有设备的员工,然后显示其在子表单中显示的设备。 *see below *见下文

Employee Rachel Downs Devices Dell Latitude Apple iPad 员工 Rachel Downs 设备 Dell Latitude苹果iPad

Instead I get the following result 相反,我得到以下结果

If I choose sort by employee with a subform, each employee is displayed with the devices they own. 如果选择带有子窗体的“按员工排序”,则会显示每个员工及其所拥有的设备。 Including employees who don't have any devices. 包括没有任何设备的员工。 I only want to display employees who currently have devices assigned. 我只想显示当前已分配设备的员工。 Any suggestions on how to do this? 有关如何执行此操作的任何建议? fyi I used the form wizard to create the forms. 仅供参考,我使用了表单向导来创建表单。

In the parent form invoke the query builder on the recordsource. 在父窗体中,在记录源上调用查询生成器。 You'll need to write a query that joins on Employees and Computers and then groups on Employee. 您需要编写一个查询,该查询在“员工”和“计算机”上联接,然后在“ Employee”上进行分组。

SELECT Employees.Eid
FROM Employees INNER JOIN Computers ON Employees.Eid = Computers.Eid
GROUP BY Employees.Eid

You can add other fields as needed from the Employees table just make sure to group on them as well. 您可以根据需要从员工表中添加其他字段,只需确保也对它们进行分组即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM