【发布时间】:2017-06-20 13:28:41
【问题描述】:
在访问中,我一直在尝试对子表单中显示的内容设置用户过滤器,该子表单是检查列表。我尝试研究的其他方法没有奏效,但我用下面的代码成功了,如果用户填写任何其他过滤器选项,它将过滤。我能弄清楚的是如何让它接受多个过滤器,除非我拼出所有可能的框组合
那么无论如何这实际上是可能的还是我需要查看其他选项?
WHERE [STATUS] = "OPEN"
AND
(ANY FORM FILTERS is not Null [Filter by all those that are not null to its matching column])
如果表单过滤器不为空,是否有任何简单的方法来包含条件
SELECT Inspections.INS_ID
,Inspections.Category
,Inspections.Assigned_Officer
,Inspections.Raised_For
,Inspections.Account
,Inspections.Number
,Inspections.Street
,Inspections.Area
,Inspections.Postcode
,Inspections.Date_Raised
,Inspections.Reason
,Inspections.INS_Comments
FROM Inspections
WHERE (
((Inspections.STATUS) = "Open")
AND (([Forms]![Manage_Open]![Filter_ID]) IS NULL)
AND (([Forms]![Manage_Open]![Filter_account]) IS NULL)
AND (([Forms]![Manage_Open]![Filter_officer]) IS NULL)
AND (([Forms]![Manage_Open]![Filter_Number]) IS NULL)
AND (([Forms]![Manage_Open]![Filter_Postcode]) IS NULL)
AND (([Forms]![Manage_Open]![Filter_Category]) IS NULL)
AND (
(([Forms]![Manage_Open]![Filter_From]) IS NULL)
AND (([Forms]![Manage_Open]![Filter_To]) IS NULL)
)
)
OR (
([Forms]![Manage_Open]![Filter_ID]) IS NOT NULL
AND ([Forms]![Manage_Open]![Filter_ID]) = [Inspections].[INS_ID]
)
OR (
([Forms]![Manage_Open]![Filter_account]) IS NOT NULL
AND ([Forms]![Manage_Open]![Filter_account]) = [Inspections].[Account]
)
OR (
([Forms]![Manage_Open]![Filter_officer]) IS NOT NULL
AND ([Forms]![Manage_Open]![Filter_officer]) = [Inspections].[Assigned_Officer]
)
OR (
([Forms]![Manage_Open]![Filter_Number]) IS NOT NULL
AND ([Forms]![Manage_Open]![Filter_Number]) = [Inspections].[Number]
)
OR (
([Forms]![Manage_Open]![Filter_Postcode]) IS NOT NULL
AND ([Forms]![Manage_Open]![Filter_Postcode]) = [Inspections].[Postcode]
)
OR (
([Forms]![Manage_Open]![Filter_Category]) IS NOT NULL
AND ([Forms]![Manage_Open]![Filter_Category]) = [Inspections].[Category]
)
OR (
(
(([Forms]![Manage_Open]![Filter_From]) IS NOT NULL)
AND (([Forms]![Manage_Open]![Filter_To]) IS NOT NULL)
)
AND ([Inspections].[Raised_For]) BETWEEN (
([Forms]![Manage_Open]![Filter_From])
AND ([Forms]![Manage_Open]![Filter_to])
) )
);
【问题讨论】: