문제

Reason: IIf([MACK.ID] Is Null,"No ID Number",
IIf([MACK.MAILCODE] Is Null,"No Mailcode",
IIf([MACK.TITLE] Is Null,"No Title")))
ect....

I am trying to create a File QC for files I import from clients. I want to check that all fields are populated as well as append ones that are not to a table and add an explanation to a created field called "Reason.

The code I have above works great for returning the reason but if a record is missing 2 fields it only returns the first one.

My question, is there a way to make it return multiple answers?

Thanks in advance for any help in this matter

도움이 되었습니까?

해결책

Syntax of IIF statement:

IIF(expression, do this if expression true, do this if expression false)

So in your example, if MACK.ID is null the first statement is true and "No ID Number" will show then the IIF statement finishes. If MACK.ID is not null then the first statement is false so the IIF statement jumps to the false part which is another IIF statement and the whole process repeats. An IIF statement only runs once.

You probably want to concatenate your IIF statements together somehow. Try something like this:

Reason: IIf([MACK.ID] Is Null,"No ID Number,","") & IIf([MACK.MAILCODE] Is
        Null,"No Mailcode,","") & IIf([MACK.TITLE] Is Null,"No Title,","")

For each test, if the expression is false you will get an empty string. If the expression is true, you will get your text plus a comma at the end which you could replace afterwards if you so wish.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top