我有两张桌子:
rapprovals_tbl
rId rAssignment rState rApprover rapprovaldt rType rNotes
12345678
1 12345679 Paid 12345678 31/05/2015 18:23 Flex
5 12345679 Approved 12345678 14/05/2015 18:23 Normal
6 12345679 Pending Normal
timerecord_tbl
RowID Assignment1 wMonth StartTime EndTime
1 12345679 Mar-15 17/03/2015 11:29 18/03/2015 16:12 Flex
5 12345679 Mar-15 17/03/2015 11:00 17/03/2015 12:00 Normal
6 12345679 Mar-15 17/03/2015 11:50 18/03/2015 16:11 Normal
我有两个组合框的表单,这两个组合框在这个源上链接和工作; 方框1 -
Select [staffid] FROM [control_tbl] WHERE [supervisorid] = '12345678'
方框2
SELECT timerecord_tbl.[RowID]
FROM timerecord_tbl
INNER JOIN rapprovals_tbl ON timerecord_tbl.RowID = rapprovals_tbl.rId
WHERE (((timerecord_tbl.[Assignment1])='" & Box 1 & "'
AND (rapprovals_tbl.[rState] is null ) Or (rapprovals_tbl.[rState] = 'Pending' )));
我想只获得与Box 2中的Box 1员工记录相关的那些RowID。
我如何解决此问题,目前列出所有行ID。
我将不胜感激任何帮助。
答案 0 :(得分:0)
尝试更改Box 2的SQL,如下所示:
SELECT timerecord_tbl.[RowID]
FROM timerecord_tbl
INNER JOIN rapprovals_tbl ON timerecord_tbl.RowID = rapprovals_tbl.rId
WHERE (timerecord_tbl.[Assignment1]='" & Box 1 & "')
AND ((rapprovals_tbl.[rState] is null ) Or (rapprovals_tbl.[rState] = 'Pending' )));
我认为@MarcB说同样的话。您的“OR”语句正在应用于整个WHERE子句,而不仅仅是其他rState过滤器。更改括号将正确分离并修复它。