IIf statement fails

  • Thread starter Thread starter Robin Chapple
  • Start date Start date
R

Robin Chapple

I have a telephone number field that I need in a report if it is
populated.

I have used this previously:

=IIf(IsNull([PhoneAH])," ",[PhoneAH] & " AH")

With the current project I still get the literal when the field is
empty.

What have I missed?

Thanks,

Robin Chapple
 
Likely the field is not empty (Null), but has an empty string ("") in it.

Try this:

=IIf(Len([PhoneAH] & "") = 0," ",[PhoneAH] & " AH")
 
Thanks Ken,

Between us we have won. Your suggestion failed so I removed the zero
and used a "1" which worked.

Then for the [PhoneBH] that did not work but this did:

=IIf(Len([PhoneAH] & "")<4," ",[PhoneAH] & " AH")

I assume that means that I have inherited some very dirty space!

I have now applied that technique to the fax and mobile numbers.

All is well. Thanks again.

Robin
 
You could have modified Ken's statement slightly to account for any number of
spaces. That way you wouldn't have to worry about the number of spaces.

=IIF(Len(Trim([PhoneAH] & ""))=0,Null,[PhoneAH] & " AH")



Robin said:
Thanks Ken,

Between us we have won. Your suggestion failed so I removed the zero
and used a "1" which worked.

Then for the [PhoneBH] that did not work but this did:

=IIf(Len([PhoneAH] & "")<4," ",[PhoneAH] & " AH")

I assume that means that I have inherited some very dirty space!

I have now applied that technique to the fax and mobile numbers.

All is well. Thanks again.

Robin

Likely the field is not empty (Null), but has an empty string ("") in it.

Try this:

=IIf(Len([PhoneAH] & "") = 0," ",[PhoneAH] & " AH")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top