IIF Statements

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to write an IIF statement that looks for blank fields.
IIF (field = blank, true, false)

Plus is a valid IIF statement:

IIF(field1 and field2 and field 3 =0, true, false)

because I have multiple criteria for a true statement
 
What are you trying to accomplish? Sounds like you are simply trying to
locate all records where field1 and field2 and field3 are blank.

If that is true, you are making it way more complex than needed...

In design view, under field 1 (in the criteria) simply put...

=""
or...
Is Null

Do the same on the same line under field2.

Do the same on the same line under field3.

Rick B

If that is not waht you want, you will have to restate your question.
 
To look for blank fields try using

[tablename].[field1] is null

or

trim([tablename].[field1])="" - if you think stray spaces might be present

Example would be

iif([tablename].[field1] is null and
[tablename].[field2]="Hello","true","false")

Hope that helps,

John
 
Ben,

You don't need an IIf() function to test whether a field is blank.
There is already a built-in function that does this.
IsNull([YourField])
.... will return True if the field is blank, and False if it contains data.

If you are testing for values in more than one field, the expression has
to evaluate each one separately. If I understand you correctly, your
second example could be written...
IIf([field1]=0 And [field2]=0 And [field3]=0, True, False)
But again, if you are just trying tio evaluate True/False, you would not
need to use IIf(). This will do...
([field1]=0 And [field2]=0 And [field3]=0)
 
The later is not a valid statement. It should be done as follows:

IIF([field1]=0 and [field2]=0 and [field3]=0,<true>,<false>)

or, if looking for null values,

IIF([field1] is null and [field2] is null and [field3] is null,<true>,<false>)

However, I agree with earlier replies that the criteria section may be an
easier and quicker way of accomplishing your goal, depending on what that
goal is.

Stumper
 
Stumper,

I think you will find that <true> and <false> as used in your suggested
expressions will not hold water.
 
Back
Top