我已经开始使用Form QueryHelp和名为DEALLOG3的Query创建一个Query by Form。我的目标是让用户能够按子市场,建筑类型和销售日期范围进行过滤。根据我现在的标准,它在大多数情况下工作正常,其中所有组合框都有值。但是,当其中一个组合框是空白时,我希望仍然可以使其他两个标准起作用,同时显示空白字段的所有记录。 (例如:坦帕子市场,[空白]建筑类型,以及2000年1月1日至2016年1月1日的销售日期。)
过去两天我一直在寻找这个景象,但找不到任何有用的东西。我想我可能正在寻找动态查询,但我不确定。以下是我目前的情况,如果您能提供帮助,请告诉我们:
SELECT DEALLOG3.PROPERTY, DEALLOG3.CODE, DEALLOG3.CLOSED, DEALLOG3.Submarket, DEALLOG3.NRA, DEALLOG3.PRICE, DEALLOG3.OCCUPANCY, DEALLOG3.[5 YR IRR], DEALLOG3.PURCHASER, DEALLOG3.SELLER, [PRICE]/[NRA]
AS PSF, [DEALLOG3]![NOI]/[PRICE]
AS [Cap Rate], DEALLOG3.[Building Type]
FROM DEALLOG3
WHERE (((DEALLOG3.CLOSED)
Between [Forms]![QueryHelp]![closeyear1]
And [Forms]![QueryHelp]![closeyear2])
AND ((DEALLOG3.Submarket)=IIf(IsNull([Forms]![QueryHelp]![Submarket]), " * " ,[Forms]![QueryHelp]![Submarket]))
AND ((DEALLOG3.[Building Type])=IIf(IsNull([Forms]![QueryHelp]![BuildingType]),"*",[Forms]![QueryHelp]![BuildingType])))
;
答案 0 :(得分:1)
在
中更改WHERE子句后再试一次WHERE DEALLOG3.CLOSED Between [Forms]![QueryHelp]![closeyear1]
AND [Forms]![QueryHelp]![closeyear2]
AND (
DEALLOG3.Submarket)=[Forms]![QueryHelp]![Submarket])
OR [Forms]![QueryHelp]![Submarket] Is Null
)
AND (
DEALLOG3.[Building Type])=[Forms]![QueryHelp]![BuildingType]
OR [Forms]![QueryHelp]![BuildingType] Is Null
)