Reputation: 149
This statement needs to get a list of emails for some friends to volunteer. I need the WHERE clause to return from the list of checkboxes only those volunteers with an email also. The following code only works when the IsVolunteer checkbox is checked and the Has an Email is checked. What is wrong with the SQL statement?
So the result should be like... Bill Turner... [email protected]... and show those checked volunteer items to requery in the form. Only those who have emails should be in this view.
If Abs(Me.hasEmailCkb.Value) = 1 And Abs(Me.CheckIsVol.Value) = 1 Then
VolToEMail = "Select * from [Members] where ([Food] = true Or [Setup] = true Or [Carpool] = true Or [Mail] = true AND [Email] <> NULL) Order By [LName] ASC"
Me.Members_subform.Form.RecordSource = VolToEMail
Thank you for helping!
Upvotes: 0
Views: 31
Reputation: 1271003
You need parentheses before the AND
:
Select *
from [Members]
where ([Food] = true Or [Setup] = true Or [Carpool] = true Or [Mail] = true) AND
([Email] IS NOT NULL)
Order By [LName] ASC;
Note that <> NULL
should be IS NOT NULL
. <> NULL
will always return NULL
, which is treated as false.
Upvotes: 1
Reputation: 27644
AND [Email] <> NULL
This does not work. You need to use:
AND [Email] IS NOT NULL
Upvotes: 0