kplona
05-08-2002, 04:12 AM
I've got two tables, one person table, one company table. There are email addresses in both. I want to pull the person email unless that is null, in which case I want to pull the company email instead. How do I write that - If, then, else...?? I got an SQL CASE statement but Access doesn't seem to accept that....
Thanks for any help anyone can provide http://www.access-programmers.co.uk/ubb/smile.gif
Assuming the tables are joined by a query:
email_used = iif(isnull([person table]![emailAddress]), [company table]![emailAddress], [person table]![emailAddress])
should do it
kplona
05-08-2002, 07:06 AM
<P> SELECT tbContacts.FNAME, tbContacts.LNAME, tbOrganizations.OrgName, tbContacts.EMAIL <P>
<P>FROM tbOrganizations INNER JOIN tbContacts ON tbOrganizations.OrgID = tbContacts.OrgID<P>
<P>email_used = iif(isnull([tbContacts]![EMAIL]), [tbOrganizations]![EMAIL], [tbContacts]![EMAIL])<P>
Is what I have and I get a missing operator error. Have I placed it incorrectly???
Not sure. I rarely use SQL directly...
Travis
05-08-2002, 08:31 AM
Try this:
SELECT [tblContacts].[FNAME], [tblContacts].[LNAME], [tblOrganizations].[OrgName], IIf(IsNull([tblContacts].[EMAIL]),[tblOrganizations].[EMAIL],[tblContacts].[EMAIL]) AS email_used
FROM tblContacts INNER JOIN tblOrganizations ON [tblContacts].[OrgID]=[tblOrganizations].[OrgID];
kplona
05-08-2002, 11:01 AM
that works! Thanks so much http://www.access-programmers.co.uk/ubb/smile.gif