UNTESTED --
First I would create a totals query to pull a list of contacts that I do not
want.
SELECT Contacts.ContactID, Events.[Event #],
FROM Contacts INNER JOIN Events ON Contacts.ContactID = Events.ContactID
WHERE Events.[Event #] Not Like "*PRESENTS" AND ((Events.[Event
Date])>#7/1/2005#))
GROUP BY Contacts.ContactID;
Then build a query from the tables and the first query
the SQL.
SELECT Contacts.LastName, Contacts.FirstName, Events.[Event #]
FROM Contacts INNER JOIN Events ON Contacts.ContactID = Events.ContactID,
FirstQuery
GROUP BY Contacts.LastName, Contacts.FirstName, Events.[Event #],
Events.[Event Date]
WHERE ((((Events.[Event #]) Like "NEGRI?" And (Events.[Event #]) AND
((Events.[Event Date])>#7/1/2005#)) OR (((Events.[Event #])="BUGSY" AND
((Events.[Event Date])>#7/1/2005#))) AND Contacts.ContactID <>
FirstQuery.ContactID
ORDER BY Contacts.LastName, Contacts.FirstName;
Why are you pulling the same field twice?
Events.[Event #], Events.[Event #]
salintag said:
Here's the SQL.
SELECT DISTINCTROW Contacts.LastName, Contacts.FirstName, Events.[Event #],
Events.[Event #]
FROM Contacts INNER JOIN Events ON Contacts.ContactID = Events.ContactID
GROUP BY Contacts.LastName, Contacts.FirstName, Events.[Event #],
Events.[Event #], Events.[Event Date]
HAVING (((Events.[Event #]) Like "NEGRI?" And (Events.[Event #]) Not Like
"*PRESENTS") AND ((Events.[Event Date])>#7/1/2005#)) OR (((Events.[Event
#])="BUGSY" And (Events.[Event #]) Not Like "*PRESENTS") AND ((Events.[Event
Date])>#7/1/2005#))
ORDER BY Contacts.LastName, Contacts.FirstName;
What I am trying to do is eliminate anyone who has *PRESENTS in the Event #
column and retain those who only have NEGRI? or BUGSY.
Thanks, salintag
:
Post your SQL.
:
In Access 2002. I have two tables - Contacts and Events. Events is a
many-to-one table joined to Contacts. If Events contains events A,B,C,D for
a particular contact, how can I eliminate that contact listing completely if
he shows D, for instance.? I've tried the normal NOT functions in many
combinations with no success, along with all three types of JOINS.