vb sql modification

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I originally was using field EmailName. Now, I'd like to allow for 2
email addresses so I created a field EmailFlag and an option group with 2
values: EmailName1 and EmailName2.

In my regular sql queries, I've modified the statement by using:
EmailName: IIf([EmailFlag]=1,[contacts].[EmailName1],[contacts].[EmailName2])

But I can't figure out how to modify sql embedded in vb to take into account
that EmailName needs to = EmailName1 or EmailName2 depending on the EmailFlag.

EmailName1 is the default, but someone may choose to have EmailName2 as
their primary email address. In any case, I'm trying to make sure that the
email address associated with the correct email flag is not null. I'd
appreicate help modifying the code:

sql = "SELECT Contacts.EmailName FROM ChapterMembers INNER JOIN " +
"Contacts ON ChapterMembers.ContactID = Contacts.ContactID " + "WHERE
(((ChapterMembers.ChapterID)=" + CStr(Me.FindChapter) + ") AND
((Contacts.EmailName) Is Not Null));"
 
Hi,



sql= "SELECT iif(emailFlag=1, emaiName1, emailName2) FROM ChaptersMembers
.... "



Hoping it may help,
Vanderghast, Access MVP
 
Michel,
Thanks for the reply. I ended up creating an "in between" query, one that
would choose from EmailName1 and EmailName2 as EmailName. Then I could use
the existing vb sql statement.
I appreciate your efforts!

Michel Walsh said:
Hi,



sql= "SELECT iif(emailFlag=1, emaiName1, emailName2) FROM ChaptersMembers
.... "



Hoping it may help,
Vanderghast, Access MVP


Stephanie said:
Hi. I originally was using field EmailName. Now, I'd like to allow for 2
email addresses so I created a field EmailFlag and an option group with 2
values: EmailName1 and EmailName2.

In my regular sql queries, I've modified the statement by using:
EmailName:
IIf([EmailFlag]=1,[contacts].[EmailName1],[contacts].[EmailName2])

But I can't figure out how to modify sql embedded in vb to take into
account
that EmailName needs to = EmailName1 or EmailName2 depending on the
EmailFlag.

EmailName1 is the default, but someone may choose to have EmailName2 as
their primary email address. In any case, I'm trying to make sure that
the
email address associated with the correct email flag is not null. I'd
appreicate help modifying the code:

sql = "SELECT Contacts.EmailName FROM ChapterMembers INNER JOIN " +
"Contacts ON ChapterMembers.ContactID = Contacts.ContactID " + "WHERE
(((ChapterMembers.ChapterID)=" + CStr(Me.FindChapter) + ") AND
((Contacts.EmailName) Is Not Null));"
 
Back
Top