nested IIF in a label addressee statement

Local time
Today, 00:04
Joined
Mar 24, 2012
Messages
6
I have fields Name1, Groups1, Name2, Groups2, and L-Name. Groups1 and Groups2 are identical dropdown lists where a single letter (e.g. "A") is selected in clicking in the appropriate box. This finds all Name1 and Name2 entries that have "A" selected; sometimes it is both, sometimes only Name1, sometimes only Name2. Name1 is never empty; sometimes Name2 is. Query works correctly.

Problem: I need an address label where the addressee contains Name1 and/or Name2 + L-name when letter "A" is checked. For example, if Name1 and Name2 of the same record have A's checked in Groups1 and Groups2, the label would be Name1 + sp + Name2 + space + L-name. If Name1 is empty but Name2 of the same record is returned in the query, the label would be: Name2 + sp + L-Name. If Name2 is empty and Name1 returns, the label would be: Name1 + sp + L-Name.

This is what I have tried (unsuccessfully):
=IIF(([Name1] IsNotNull & IIF[Name2] ISNotNull, [Name1] & " " [Name2] & " " & [L-Name]) , IIF([Name1] IsNull, [Name2] & " " & [L-Name], [Name1] & " " & [L-Name]))
 
Last edited:
Try this;

=IIf(Nz([Name1],"")="",[Name2] & " " & [L-Name],IIf(Nz([Name2],"")="",[Name1] & " " & [L-Name],[Name1] & " " & [Name2] & " " & [L-Name]))
 
Beetle, thanks for your quick response. Your statement still returns both name1 and name2 for all records that are returned by the query. This is only my second time on this site, but I'm going to try to attach a pic of the query return. You see that Sarah Allen and Eddie Aslin do NOT have an "A" in their respective groups1/groups2 field; so their names should not appear on the label -- but they do. Also, if you care to submit another or modified solution, I would certainly appreciate it, and since asking is free, I would need the word "and" inserted between name1 and name2 when both are returned for the same record: e.g.
[Name1] & " " & "and" " " [Name2] & " " & [L-Name]
 

Attachments

  • DB_fields.JPG
    DB_fields.JPG
    29.6 KB · Views: 110
Last edited:
Still not sure I completely understand what you're after, but give this a shot;

=IIf(InStr([Groups1],"A")>0 And InStr([Groups2],"A")>0, [Name1] & " and " & [Name2] & " " & [L-Name], IIf(Instr([Groups1], "A")>0, [Name1] & " " & [L-Name], [Name2] & " " & [L-Name]))
 
Well Bailey, I'm not even sure how to "reply" to the thread and your last statement. Geez, it is completely Greek to me -- but it works!! I am so impressed with your expert help, with the speed of your replies, with your making a second attempt for me, and the helpfulness of this site. Thank you so very much.
 
Happy to help.

Welcome to the forum, BTW.
 

Users who are viewing this thread

Back
Top Bottom