Calling a query from within another one
Hi,
I get a dB engine error from Access 2000 when calling a query from
within another query. The message is (free translation) "The dB engine
could not find the table or query.... check if it's mis-spell.." The
queries are from text files and are not part of any database I use
"SQL.LoadFromFile(.SQL')". I have some parametrized queries that use
parameters from another query in the WHERE clause
(:QueryAlias.FieldName) an there is no problem. But when I use another
query name in the FROM clause of a query The exception occurs.
I do not want to put these queries in the Access DataBase. Is there a
way to temporarily append these queries in the DataBase (collection of
tables) and removed it after? May be there is another solution?
I hope it's clear enough, if not see the queries below
Thanks in advance
Serge
-First query (when this query is part of the DataBasethere is no
problem)
SELECT DRAWING_NO, REV_NO, SUM(QTY_TO_SHIP) AS xQTY, MAX(PROJECT_NO) AS
PROJ_NO
FROM PROJECT_DTL AS SumToShipRealInventory
WHERE QTY_TO_SHIP > 0
GROUP BY DRAWING_NO, REV_NO
ORDER BY DRAWING_NO
-Second query
SELECT DISTINCT c.CLIENT_NO, c.COMP_NAME, p.CLIENT_NO, pd.DRAWING_NO,
pd.REV_NO, i.PART_NO,
i.REV_NO, i.DESCRIP, i.QTY, IIF((i.QTY <= pd.xQTY), i.QTY,
pd.xQTY) , i.PART_COST,
(xQTY * i.PART_COST) AS TotAmount
FROM ((SumToShipRealInventory AS pd RIGHT JOIN INVENTORY AS i ON
(i.REV_NO = pd.REV_NO)
AND (i.PART_NO = pd.DRAWING_NO)) LEFT JOIN PROJET AS p ON
p.PROJECT_NO = pd.PROJ_NO)
LEFT JOIN CLIENT AS c ON c.CLIENT_NO = p.CLIENT_NO
WHERE pd.xQTY > 0
ORDER BY c.COMP_NAME, i.PART_NO, i.REV_NO;