sql code not working properly

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
 
J

John Spencer (MVP)

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]" & _
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top