在Access中过滤报表以显示2个不同的值

时间:2017-09-29 13:31:11

标签: sql ms-access report

我目前有一份报告,根据此标准对其进行过滤[请输入QMWR,GRA,ER或ERG:]。我想添加一个新选项“Both”来选择ER和ERG。我在下面提到了这个问题。

SELECT tblQMWR.QuarterID, tblQMWR.Page, tblQMWR.ProjectNum, tblQMWR.Employee, tblQMWR.DateSent, tblQMWR.DateReceived, tblImport.[Child PI S Name] AS PIName, tblQuarters2.Quarter, tblImport.[Child SPFMS Initials], tblPIContact.Office, tblQMWR.Notes, tblQuarters2.Type
FROM ((tblImport 
  RIGHT JOIN tblQMWR ON tblImport.[Child Flex Value] = tblQMWR.ProjectNum) 
  LEFT JOIN tblQuarters2 ON tblQMWR.QuarterID = tblQuarters2.QuarterID) 
  LEFT JOIN tblPIContact ON tblImport.[Child Department] = tblPIContact.Department
WHERE (((tblQMWR.Page) Is Not Null) 
  AND ((tblQuarters2.Quarter)=[Please enter a semester/ quarter code:]) 
  AND ((tblQuarters2.Type)=[Please enter QMWR, GRA, ER, or ERG:]) 
  AND ((tblQMWR.ProjectNum) Is Not Null))
ORDER BY tblImport.[Child PI S Name], tblQMWR.ProjectNum;

感谢您的帮助!我最后添加了第二个对话框,以便可以使用两种类型的任意组合。

1 个答案:

答案 0 :(得分:0)

试试这个(换了1行)

SELECT tblQMWR.QuarterID, tblQMWR.Page, tblQMWR.ProjectNum, tblQMWR.Employee, tblQMWR.DateSent, tblQMWR.DateReceived, tblImport.[Child PI S Name] AS PIName, tblQuarters2.Quarter, tblImport.[Child SPFMS Initials], tblPIContact.Office, tblQMWR.Notes, tblQuarters2.Type
FROM ((tblImport 
  RIGHT JOIN tblQMWR ON tblImport.[Child Flex Value] = tblQMWR.ProjectNum) 
  LEFT JOIN tblQuarters2 ON tblQMWR.QuarterID = tblQuarters2.QuarterID) 
  LEFT JOIN tblPIContact ON tblImport.[Child Department] = tblPIContact.Department
WHERE (((tblQMWR.Page) Is Not Null) 
  AND ((tblQuarters2.Quarter)=[Please enter a semester/ quarter code:]) 
  AND ([Please enter QMWR, GRA, ER, or ERG:] Like "*" & tblQuarters2.Type & "*" ) 
  AND ((tblQMWR.ProjectNum) Is Not Null))
ORDER BY tblImport.[Child PI S Name], tblQMWR.ProjectNum;