Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top