S
SillySally
Hi. I'm trying to add an IIF statement within an existing
select statement. I'm building mailing labels and I'm
tyring to say that if AddressFlag = 1, use
MailingAddress1, OptAddress1, City1, StateOrProvince1 and
PostalCode1. And if AddressFlag = 2, use these fields
with the "2" desgination (e.g. MailingAddress2).
IIf(([AddressFlag]=1), c1.MailingAddress1
& ", "+c1.OptAddress1 AS Address, c1.City1, UCase
(c1.StateOrProvince1) AS State, c1.PostalCode1)
This gets hung up on on AS Address. And I haven't even
gotten to AddressFlag=2!
I've posted the sql I'm trying to adjust for my new
address considerations:
SELECT Nz(c1.NickName,c1.FirstName) & " " & c1.LastName AS
[Member Name], (SELECT Nz(c2.[NickName],c2.[FirstName])
& " " & c2.[LastName] AS [SONm] FROM Contacts c2 WHERE
c2.ContactID = Nz(c1.SignificantOtherID,-9999)) AS [SO
Name], Nz(c1.CompanyName," ") AS [Company Name], Nz
(c1.ContactNickName,c1.ContactFirstName) & " " &
c1.ContactLastName AS ContactName, c1.MailingAddress
& ", "+c1.OptAddress AS Address, c1.City, UCase
(c1.StateOrProvince) AS State, c1.PostalCode,
c1.SignificantOtherID, c1.SignificantOtherID, c1.Newsletter
FROM Contacts AS c1
WHERE (c1.SignificantOtherID>c1.ContactID Or
c1.SignificantOtherID Is Null And c1.Newsletter=Yes)
ORDER BY c1.PostalCode;
Can I just plop an IIF in the middle of the select?
Thanks for the help!
select statement. I'm building mailing labels and I'm
tyring to say that if AddressFlag = 1, use
MailingAddress1, OptAddress1, City1, StateOrProvince1 and
PostalCode1. And if AddressFlag = 2, use these fields
with the "2" desgination (e.g. MailingAddress2).
IIf(([AddressFlag]=1), c1.MailingAddress1
& ", "+c1.OptAddress1 AS Address, c1.City1, UCase
(c1.StateOrProvince1) AS State, c1.PostalCode1)
This gets hung up on on AS Address. And I haven't even
gotten to AddressFlag=2!
I've posted the sql I'm trying to adjust for my new
address considerations:
SELECT Nz(c1.NickName,c1.FirstName) & " " & c1.LastName AS
[Member Name], (SELECT Nz(c2.[NickName],c2.[FirstName])
& " " & c2.[LastName] AS [SONm] FROM Contacts c2 WHERE
c2.ContactID = Nz(c1.SignificantOtherID,-9999)) AS [SO
Name], Nz(c1.CompanyName," ") AS [Company Name], Nz
(c1.ContactNickName,c1.ContactFirstName) & " " &
c1.ContactLastName AS ContactName, c1.MailingAddress
& ", "+c1.OptAddress AS Address, c1.City, UCase
(c1.StateOrProvince) AS State, c1.PostalCode,
c1.SignificantOtherID, c1.SignificantOtherID, c1.Newsletter
FROM Contacts AS c1
WHERE (c1.SignificantOtherID>c1.ContactID Or
c1.SignificantOtherID Is Null And c1.Newsletter=Yes)
ORDER BY c1.PostalCode;
Can I just plop an IIF in the middle of the select?
Thanks for the help!