sub5
Programmer
- Oct 12, 2005
- 104
Hello all,
I am trying to cut down on queries by incorporating some subqueries into their parents. In this case Query2 was originally set-up to find unmatched records from Query1.
The code below doesn't exclude the records from Query1.
Originally I thought I would use the NOT IN clause, but I get the error message:
"You have written a subquery that can return more than one field without using the EXISTS reserved word in the main queries FROM clause. Revise the SELECT statment of the subquery to request only one field."
SELECT [Refno] & " / " & [Product] AS comb, [T-REF].REFno, [Tp-Product].Product
FROM [Tp-Product] RIGHT JOIN (([T-REF] RIGHT JOIN [T-Doc] ON [T-REF].REFID = [T-Doc].refID) RIGHT JOIN [T-DocEng] ON [T-Doc].DocID = [T-DocEng].DocID) ON [Tp-Product].ProductID = [T-DocEng].productID
WHERE ((([T-DocEng].DocEngID)<>Exists (SELECT [T-DocEng].DocEngID, [Tp-ProductNoToContract].ProductRegID
FROM [T-DocEng] INNER JOIN [Tp-ProductNoToContract] ON [T-DocEng].DocEngID = [Tp-ProductNoToContract].DocEngID
WHERE ((([Tp-ProductNoToContract].ProductRegID) like [forms]![frm1]![cbo1))
))
GROUP BY [T-REF].REFno, [Tp-Product].Product
ORDER BY [T-REF].REFno, [Tp-Product].Product;
How do I modify the code so that the main query EXCLUDES all the records in the subquery?
Thankyou
I am trying to cut down on queries by incorporating some subqueries into their parents. In this case Query2 was originally set-up to find unmatched records from Query1.
The code below doesn't exclude the records from Query1.
Originally I thought I would use the NOT IN clause, but I get the error message:
"You have written a subquery that can return more than one field without using the EXISTS reserved word in the main queries FROM clause. Revise the SELECT statment of the subquery to request only one field."
SELECT [Refno] & " / " & [Product] AS comb, [T-REF].REFno, [Tp-Product].Product
FROM [Tp-Product] RIGHT JOIN (([T-REF] RIGHT JOIN [T-Doc] ON [T-REF].REFID = [T-Doc].refID) RIGHT JOIN [T-DocEng] ON [T-Doc].DocID = [T-DocEng].DocID) ON [Tp-Product].ProductID = [T-DocEng].productID
WHERE ((([T-DocEng].DocEngID)<>Exists (SELECT [T-DocEng].DocEngID, [Tp-ProductNoToContract].ProductRegID
FROM [T-DocEng] INNER JOIN [Tp-ProductNoToContract] ON [T-DocEng].DocEngID = [Tp-ProductNoToContract].DocEngID
WHERE ((([Tp-ProductNoToContract].ProductRegID) like [forms]![frm1]![cbo1))
GROUP BY [T-REF].REFno, [Tp-Product].Product
ORDER BY [T-REF].REFno, [Tp-Product].Product;
How do I modify the code so that the main query EXCLUDES all the records in the subquery?
Thankyou