IIF, Len; IIF(Len) (1 Viewer)

mjdemaris

Working on it...
Local time
Today, 07:39
Joined
Jul 9, 2015
Messages
426
Is it possible to use this:
Code:
IIF(LEN(txtbox)=3,true,false))

I have not been successful so far. I have a text box that says it has 3 spaces on a report, but the VBA says the length is 0, and not null.

I am attempting to combine some contact information into one text box, but only if a first name exists, otherwise it needs to be null. Then the text box should be able to shrink on the report/print view.
1649467159612.png


code in query:
Code:
Contact: IIf(Nz([GEN_Contacts].[FirstName],Null)=Null,Null,[GEN_Contacts].[FirstName] & " " & [GEN_Contacts].[LastName] & " " & Format$([GEN_Contacts].[Phone1],"(000) 000-0000") & " " & [GEN_Contacts].[EmailAddress])

code in text box acting as a label:
Code:
=IIf(Trim(Nz([Contact],""))="","","Contact")

Thanks,
Mike
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:39
Joined
May 7, 2009
Messages
19,233
you can simplify your query expression:
Code:
Contact: [GEN_Contacts].[FirstName] + (" " & [GEN_Contacts].[LastName] & " " & Format$([GEN_Contacts].[Phone1],"(000) 000-0000") & " " & [GEN_Contacts].[EmailAddress])
 

mjdemaris

Working on it...
Local time
Today, 07:39
Joined
Jul 9, 2015
Messages
426
@arnelgp ah, that's the concatenation using +, which results in null if combining null and string... that thread is on my reading list.

Thanks arnelgp
 

Users who are viewing this thread

Top Bottom