MS Access IIF语句缺少结束括号

时间:2016-09-19 02:20:02

标签: access parentheses iif

我正在努力弄清楚下面的表达中缺少什么。我感谢所有的帮助!

SKU_Qty: 
Sum(IIf( [SKU Breakout 004]![Year_Week] >= [z Calendar Reset]![Year-Week-Disco] AND [SKU Breakout 004]![Year_Week] < [z Calendar Reset]![Year-Week-Ship], IIf( [SKU Breakout 003]![Distribution Type] = "DELETE",0,[SKU Breakout 003]![SKU_Cust_Mix_Current%]*[SKU Breakout 004]![Qty], IIf([SKU Breakout 004]![Year_Week] < [z Calendar Reset]![Year-Week-Disco], [SKU Breakout 003]![SKU_Cust_Mix_Current%]*[SKU Breakout 004]![Qty] ,  [SKU Breakout 003]![SKU_Cust_Mix_Future%]*[SKU Breakout 004]![Qty]))

1 个答案:

答案 0 :(得分:0)

你有4个开括号,只有2个关闭,所以你也应该关闭其他两个。

你应该略微勾勒出你的表达,不要迷失它的嵌套方式:

Sum(
    IIf( 
        [SKU Breakout 004]![Year_Week] >= [z Calendar Reset]![Year-Week-Disco] 
        AND [SKU Breakout 004]![Year_Week] < [z Calendar Reset]![Year-Week-Ship], 
        IIf( 
            [SKU Breakout 003]![Distribution Type] = "DELETE",
            0,
            [SKU Breakout 003]![SKU_Cust_Mix_Current%]*[SKU Breakout 004]![Qty], 
            IIf(
                [SKU Breakout 004]![Year_Week] < [z Calendar Reset]![Year-Week-Disco], 
                [SKU Breakout 003]![SKU_Cust_Mix_Current%]*[SKU Breakout 004]![Qty] ,  
                [SKU Breakout 003]![SKU_Cust_Mix_Future%]*[SKU Breakout 004]![Qty]
                )
           )

现在你清楚地看到有些东西丢失了。也许你需要这个:

Sum(
    IIf( 
        [SKU Breakout 004]![Year_Week] >= [z Calendar Reset]![Year-Week-Disco] 
        AND [SKU Breakout 004]![Year_Week] < [z Calendar Reset]![Year-Week-Ship], 
        IIf( 
            [SKU Breakout 003]![Distribution Type] = "DELETE",
            0,
            [SKU Breakout 003]![SKU_Cust_Mix_Current%]*[SKU Breakout 004]![Qty]
        ), 
        IIf(
            [SKU Breakout 004]![Year_Week] < [z Calendar Reset]![Year-Week-Disco], 
            [SKU Breakout 003]![SKU_Cust_Mix_Current%]*[SKU Breakout 004]![Qty] ,  
            [SKU Breakout 003]![SKU_Cust_Mix_Future%]*[SKU Breakout 004]![Qty]
            )
       )
)