【问题标题】:MS Access Query Criteria IIf true then <MS Access 查询条件 IIf true then <
【发布时间】:2018-11-22 12:48:20
【问题描述】:

我有一个 MS Access 2007 查询,其条件如下 - 但它不起作用!

IIf([Forms]![CSL_CSD_Log]![Reason_Category]=1,<6,[Forms]![CSL_CSD_Log]![Reason_Category])

我不明白为什么 TRUE 结果没有给我所有

我错过了什么吗??

提前致谢。

【问题讨论】:

  • 你能发布你的查询的SQL吗?我认为您需要 EVAL 您的 IIf 语句才能按您期望的方式工作。
  • @Minty 这是我的 SQL 代码 'SELECT TBL_Descriptor_Values.Descriptor_ID、TBL_Descriptor_Values.Descriptor、TBL_Descriptor_Values.Descriptor_Category FROM TBL_Descriptor_Values WHERE ((((TBL_Descriptor_Values.Descriptor_Category)=IIf([Forms]![CSLC_CSD]) ]=1,(TBL_Descriptor_Values.Descriptor_Category)

标签: ms-access ms-access-2007


【解决方案1】:

转到 SQL 视图并尝试 where 子句:

WHERE 
    IIF([Forms]![CSL_CSD_Log]![Reason_Category] = 1, [FieldToFilter] < 6, [FieldToFilter] = [Forms]![CSL_CSD_Log]![Reason_Category])

【讨论】:

    【解决方案2】:

    感谢您的回复,他们把我带到了另一个方向,我设法让它根据需要工作。 它可能不是最漂亮的编码,但是嘿:)

    SELECT TBL_Descriptor_Values.Descriptor_ID, TBL_Descriptor_Values.Descriptor, 
    TBL_Descriptor_Values.Descriptor_Category
    FROM TBL_Descriptor_Values
    WHERE (((IIf([Forms]![CSL_CSD_Log]![Reason_Category]<2,[TBL_Descriptor_Values].            
    [Descriptor_Category]))<6) AND ((TBL_Descriptor_Values.Enabled)=-1)) OR 
    (((TBL_Descriptor_Values.Enabled)=-1) AND ((IIf([Forms]![CSL_CSD_Log]! 
    [Reason_Category]=4,[TBL_Descriptor_Values].[Descriptor_Category]))=4)) OR 
    (((TBL_Descriptor_Values.Enabled)=-1) AND ((IIf([Forms]![CSL_CSD_Log]! 
    [Reason_Category]=5,[TBL_Descriptor_Values].[Descriptor_Category]))=5)) OR 
    (((TBL_Descriptor_Values.Enabled)=-1) AND ((IIf([Forms]![CSL_CSD_Log]! 
    [Reason_Category]=6,[TBL_Descriptor_Values].[Descriptor_Category]))=6))
    ORDER BY TBL_Descriptor_Values.Order;
    

    再次感谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多