Can't seem to get rid of record from query

P

Papa Jonah

I am trying to create a query that will find all activities in the database
that are not "Meeting" or "Loss of a loved one". The following seems to work
except for the loss of loved one part. It still shows up. What am I doing
wrong? I have included the SQL in hopes that that will help.
Thanks,
Papa
SELECT tblActivities.DateBegin AS [Date], [zlookup CallNature].Activity,
tblActivities.CallSummary AS Summary, [zlookup Shift].txtDept AS Dept,
[zlookup Shift].txtShift AS Shift, [zlookup Station].Station
FROM ((tblActivities LEFT JOIN [zlookup Shift] ON tblActivities.Shift =
[zlookup Shift].numShiftID) LEFT JOIN [zlookup Station] ON
tblActivities.numstationvisits = [zlookup Station].StationID) LEFT JOIN
[zlookup CallNature] ON tblActivities.CallNature = [zlookup
CallNature].ActivityID
WHERE (((tblActivities.DateBegin)>#4/30/2007#) AND (([zlookup
CallNature].Activity)<>"Meeting" Or ([zlookup CallNature].Activity)="Loss of
loved one"))
ORDER BY tblActivities.DateBegin;
 
J

Jason Lepack

Or ([zlookup CallNature].Activity)<>"Loss of loved one"))

Cheers,
Jason Lepack
 
J

John W. Vinson

I am trying to create a query that will find all activities in the database
that are not "Meeting" or "Loss of a loved one". The following seems to work
except for the loss of loved one part. It still shows up. What am I doing
wrong? I have included the SQL in hopes that that will help.

The problem is the convoluted nature of the reasoning behind "not equal"
logic.

If the value of Activity is "Loss of loved one" then it is certainly not equal
to "Meeting". Therefore the first term of your OR clause will be TRUE (it is
true that the value is <> "Meeting") and it will return the record.

Tryu

SELECT tblActivities.DateBegin AS [Date], [zlookup CallNature].Activity,
tblActivities.CallSummary AS Summary, [zlookup Shift].txtDept AS Dept,
[zlookup Shift].txtShift AS Shift, [zlookup Station].Station
FROM ((tblActivities LEFT JOIN [zlookup Shift] ON tblActivities.Shift =
[zlookup Shift].numShiftID) LEFT JOIN [zlookup Station] ON
tblActivities.numstationvisits = [zlookup Station].StationID) LEFT JOIN
[zlookup CallNature] ON tblActivities.CallNature = [zlookup
CallNature].ActivityID
WHERE (((tblActivities.DateBegin)>#4/30/2007#) AND (([zlookup
CallNature].Activity) NOT IN( "Meeting", "Loss of loved one")))
ORDER BY tblActivities.DateBegin;


John W. Vinson [MVP]
 
P

Papa Jonah

This is a smack my forehead moment.
Thanks!

Jason Lepack said:
Or ([zlookup CallNature].Activity)<>"Loss of loved one"))

Cheers,
Jason Lepack

I am trying to create a query that will find all activities in the database
that are not "Meeting" or "Loss of a loved one". The following seems to work
except for the loss of loved one part. It still shows up. What am I doing
wrong? I have included the SQL in hopes that that will help.
Thanks,
Papa
SELECT tblActivities.DateBegin AS [Date], [zlookup CallNature].Activity,
tblActivities.CallSummary AS Summary, [zlookup Shift].txtDept AS Dept,
[zlookup Shift].txtShift AS Shift, [zlookup Station].Station
FROM ((tblActivities LEFT JOIN [zlookup Shift] ON tblActivities.Shift =
[zlookup Shift].numShiftID) LEFT JOIN [zlookup Station] ON
tblActivities.numstationvisits = [zlookup Station].StationID) LEFT JOIN
[zlookup CallNature] ON tblActivities.CallNature = [zlookup
CallNature].ActivityID
WHERE (((tblActivities.DateBegin)>#4/30/2007#) AND (([zlookup
CallNature].Activity)<>"Meeting" Or ([zlookup CallNature].Activity)="Loss of
loved one"))
ORDER BY tblActivities.DateBegin;
 

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

Similar Threads


Top