Hi,
Is short, your solution with strict = would have been
WHERE udref NOT IN( SELECT ExcludeItems FROM qryExcluedReturnItemWords)
but rather than having equality, you have patterns and need to use LIKE.
Right? If so...
FIRST, why your solution does not work.
The ON clause is logically evaluated AFTER the cartesian join is done.
As example. if qrySelectedRepReturnsInXDays.udref = { 1, 2, 3} and
qryExcluedReturnItemWords.ExcludeItems ={ 2, 101, 103}
then, after the cartesian join, we have
udref exlcudeItems
1 2
1 101
1 103
2 2
2 101
2 103
3 2
3 101
3 103
then, evaluate the ON clause, here, for simplicity, say: ON udref <>
excludeItems
udref exlcudeItems ON_evaluation
1 2 true
1 101 true
1 103 true
2 2 false
2 101 true
2 103 true
3 2 true
3 101 true
3 103 true
and we keep all those produced records (produced by the cartesian join)
where the ON evaluates to TRUE... we see that only one result of the
cartesian product will be removed. In fact, if we have replaced the <> by a
=, only one row will be kept, so, the two cases, <> and =, are somehow
"complementary" (because there are no null values).
NOW, how to make it to work.
Note that with <>, we removed ONE record from the cartesian join. We also
have data "in excess". So, what about a GROUP BY to solve these two
problems:
a possible solution is to GROUP BY udref, and to COUNT the number of records
after the ON clause:
SELECT udref, LAST(item)
FROM ... ON ...
GROUP BY udref
HAVING COUNT(*)= ( SELECT COUNT(*) FROM qryExcluedReturnItemWords)
Indeed, the record with
qrySelectedRepReturnsInXDays.udref Not Like "*" &
qryExcluedReturnItemWords.ExcludeItems & "*"
will have at least ONE LESS record (as we illustrated) than there are in the
original qryExcluedReturnItemWords, and so, has to be removed from the final
result to get what we want! (I assume).
Hoping it may help,
Vanderghast, Access MVP