IIF与Access 2007中的声明不同

时间:2014-07-09 10:22:30

标签: mysql sql ms-access ms-access-2007

我试图让这个QC显示文件失败的原因。我现有的质量控制工作很有效,但是当我尝试将原因全部用于无效的邮政编码时。如果由于任何其他原因导致QC捕获和错误,则会给出该原因以及无效的邮政编码。我已将我的理由逻辑放在下面,并指出了我认为存在这个问题的领域。

Reason: IIf([CNMC Import.Gf_Date] Is Null,"No gift date, ","") & IIf([CNMC Import.Gf_Amount] Is Null,"No gift amount, ","") &
IIf([CNMC Import.Gf_CnBio_Key_Indicator] Is Null,"No individual or organization indicator, ","") &
IIf([CNMC Import.Gf_CnAdrSal_Addressee] Is Null,"No Addressee, ","") &
IIf([CNMC Import.Gf_CnAdrSal_Salutation] Is Null,"No Salutation, ","") &
IIf([CNMC Import.Gf_CnAdrPrf_Addrline1] Is Null,"No street address, ","") &
IIf([CNMC Import.Gf_CnAdrPrf_City] Is Null,"No city, ","") &
IIf([CNMC Import.Gf_CnAdrPrf_State] Is Null,"No state, ","") &
IIf([CNMC Import.Gf_CnAdrPrf_ZIP] Is Null,"No Zip Code, ","") & 
**IIf(([CNMC Import.Gf_CnAdrPrf_ZIP] Not Like "#####-####" & [CNMC Import.Gf_CnAdrPrf_ZIP]) Not Like "#####","Invalid zip code, ","")**

2 个答案:

答案 0 :(得分:1)

如果您尝试合并两项检查,则无法使用仅将字符串合并在一起的&符号。

而不是

IIf(([CNMC Import.Gf_CnAdrPrf_ZIP] Not Like "#####-####" & [CNMC Import.Gf_CnAdrPrf_ZIP]) Not Like "#####","Invalid zip code, ","")

IIf([CNMC Import.Gf_CnAdrPrf_ZIP] Not Like "#####-####" AND [CNMC Import.Gf_CnAdrPrf_ZIP] Not Like "#####","Invalid zip code, ","")

答案 1 :(得分:1)

试试这个(使用IIf 2次):

IIf([CNMC Import.Gf_CnAdrPrf_ZIP] Like "#####-####", ",", IIf([CNMC Import.Gf_CnAdrPrf_ZIP]) Like "#####", ",", "Invalid zip code")