简体   繁体   English

Access / VBA 3075-Iif中的参数数量错误

[英]Access/VBA 3075 - Wrong number of arguments in Iif

iif((([START DATE]<(cdate(format(year() & [WinterStartMonth] & [WinterStartDay],"####/##/##")))) AND ([START DATE]>(cdate(format(year() & [SummerStartMonth] & [SummerStartDay], "####/##/##"))))), (DateAdd("d", [WinterInspectionDropDead], [START DATE])), (DateAdd("d", [SummerInspectionDropDead], [START DATE]))) AS dropDead

Can anybody spot the issue? 有人可以发现问题吗? I think I've gone OTT with the brackets but I can't seem to shake the error. 我想我已经在OTT括起来了,但是我似乎无法摆脱这个错误。

You can usually use VBA to easily spot the errors, so: 通常,您可以使用VBA轻松发现错误,因此:

IIf([START DATE] < DateSerial(Year(Date),[WinterStartMonth],[WinterStartDay]) _
And [START DATE] > DateSerial(Year(Date),[SummerStartMonth],[SummerStartDay]), _
DateAdd("d", [WinterInspectionDropDead], [START DATE]), DateAdd("d", _
[SummerInspectionDropDead], [START DATE]))

Just remove the line break characters for SQL: 只需删除SQL的换行符即可:

IIf([START DATE] < DateSerial(Year(Date), [WinterStartMonth], [WinterStartDay]) 
  And [START DATE] > DateSerial(Year(Date),[SummerStartMonth], [SummerStartDay]),
  DateAdd("d", [WinterInspectionDropDead], [START DATE]),
  DateAdd("d", [SummerInspectionDropDead], [START DATE])) As Result

Or probably better: 也许更好:

IIf([START DATE] < DateSerial(Year(Date), [WinterStartMonth], [WinterStartDay]) 
  And [START DATE] > DateSerial(Year(Date),[SummerStartMonth],[SummerStartDay]),
 [START DATE] + [WinterInspectionDropDead], 
 [START DATE] + [SummerInspectionDropDead]) 
As Result

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM