ajalwaysus - Both of your code samples worked correctly in my project. I have been testing these, and some new ideas of my own.
The first code
- SELECT tTitles.FKey
-
FROM tTitles
-
WHERE tTitles.[ptr->tAAA] IN
-
(SELECT [ptr->tAAA]
-
FROM tTitles
-
WHERE Title Like "*John*")
-
slows down appreciably when the tables become large. I suspect that the "IN" feature doesn't like 10K+ items.
The second code
- SELECT tTitles.FKey
-
FROM tTitles INNER JOIN (SELECT [ptr->tAAA]
-
FROM tTitles WHERE Title Like "*John*") AS ALIAS1
-
on tTitles.[ptr->tAAA] = ALIAS1.[ptr->tAAA]
-
needs aliases, whereas using a saved query does not. This was the key I needed. Following up on this idea, I find that expanding this to use in my project required each item selected in the subQuery also must have an alias. So the subQuery becomes
- SELECT tAAA.Field1 AS F1, tAAA.Field2 AS F2, .......
-
FROM tAAA INNER JOIN ......
-
WHERE ...
-
Then the query, as a general case, becomes
-
SELECT qry.F2, qry.F1, ...
-
FROM
-
(SELECT tAAA.Field1 AS F1, tAAA.Field2 AS F2, .......
-
FROM tAAA INNER JOIN ......
-
WHERE ...) as qry
-
WHERE ([conditions])
-
ORDER BY Fn1, Fn2, ...
Mike - For, lets say, an Address Book, a record in tAddrBk would contain data about an individual or company. The name might be Robert Kennedy or Oakland Auto Repair, stored in another table, tNames. Also in tNames are alternate names, such as Bobby Kennedy or "Ken", the mechanic and owner of Oakland Auto. Searching for Bobby or Ken needs to find the alternate names, but display the primary names. tNames has a field Alt (Y/N). Therefore, your suggestion does not solve my problem.