sql code not working properly

  • Thread starter Thread starter Antonio
  • Start date Start date
A

Antonio

Good morning, all, I am trying to get the e-mails of all
the customers that subscribe to a title and that are
currently in an active status.
the sql I have in my code is:

sql = "SELECT CustomerDB.[E-mail Address] FROM
CustomerDB WHERE CustomerDB.SubscriptionTitle1 ='" &
mySubcode & "' & _
"'AND CustomerDB.InactiveCustomer = No GROUP BY CustomerDB.
[E-mail Address] HAVING CustomerDB.[E-mail Address]
Like '*'"

The problem is that lists all the e-mail addresses for all
the customers subscribing to the title, even if their
account is inactive. Also, I have titles that have
apostrophe in it and I get an error message when I do a
search on those. Any idea? Thanks, Antonio
 
sql = "SELECT CustomerDB.[E-mail Address]" & _
" FROM CustomerDB" & _
" WHERE CustomerDB.SubscriptionTitle1 =""" & mySubcode & _
""" AND CustomerDB.InactiveCustomer = False" & _
" AND CustomerDB.[E-mail Address] Is Not Null"
" GROUP BY CustomerDB.[E-mail Address]" & _
 
Back
Top