A
Allen_N
Here's a weird one. The code
Set qy = CurrentDb.QueryDefs(strSourceQuery)
strSQL = qy.SQL
Set qy = CurrentDb.QueryDefs("Kits Found Special")
qy.SQL = strSQL
produces error 3131: "Syntax error in FROM clause", despite the fact that
the 1st query works fine if run from the database window.
After the 2nd line, strSQL is
"SELECT [Sub Kit Comps].KitItem
FROM [SELECT [Sub Kit Comps].KitItem, [Sub Kit Comps].ITEM, [Sub Kit
Comps].PER, [Sub Kit Comps_1].ITEM, [Sub Kit Comps_1].PER FROM [Sub Kit
Comps] INNER JOIN [Sub Kit Comps] AS [Sub Kit Comps_1] ON [Sub Kit
Comps].KitItem = [Sub Kit Comps_1].KitItem WHERE ((([Sub Kit
Comps].ITEM)='600-211-1231') AND (([Sub Kit Comps].PER)=4) AND (([Sub Kit
Comps_1].ITEM)='600-212-1511') AND (([Sub Kit Comps_1].PER)=2))]. AS
[%$##@_Alias]
WHERE [Sub Kit Comps].KitItem IN (SELECT KitItem AS k2 FROM [Sub Kit Comps]
AS [Sub Kit Comps_2] GROUP BY KitItem HAVING COUNT (1) < 7);"
(note that Access added the "]. AS [%$##@_Alias]" foolishness, not I).
If I look at this string by hovering the cursor over it while execution is
paused, it shows 2 rectangular symbols before the 1st "FROM". Thinking that
the code was getting a CR-LF that it didn't like, I killed the EOL's in the
original query (from within the database window), but this did not prevent
the error.
Has anyone seen this before? Is it something to do with the length of the
string strSQL?
Thanks!
Set qy = CurrentDb.QueryDefs(strSourceQuery)
strSQL = qy.SQL
Set qy = CurrentDb.QueryDefs("Kits Found Special")
qy.SQL = strSQL
produces error 3131: "Syntax error in FROM clause", despite the fact that
the 1st query works fine if run from the database window.
After the 2nd line, strSQL is
"SELECT [Sub Kit Comps].KitItem
FROM [SELECT [Sub Kit Comps].KitItem, [Sub Kit Comps].ITEM, [Sub Kit
Comps].PER, [Sub Kit Comps_1].ITEM, [Sub Kit Comps_1].PER FROM [Sub Kit
Comps] INNER JOIN [Sub Kit Comps] AS [Sub Kit Comps_1] ON [Sub Kit
Comps].KitItem = [Sub Kit Comps_1].KitItem WHERE ((([Sub Kit
Comps].ITEM)='600-211-1231') AND (([Sub Kit Comps].PER)=4) AND (([Sub Kit
Comps_1].ITEM)='600-212-1511') AND (([Sub Kit Comps_1].PER)=2))]. AS
[%$##@_Alias]
WHERE [Sub Kit Comps].KitItem IN (SELECT KitItem AS k2 FROM [Sub Kit Comps]
AS [Sub Kit Comps_2] GROUP BY KitItem HAVING COUNT (1) < 7);"
(note that Access added the "]. AS [%$##@_Alias]" foolishness, not I).
If I look at this string by hovering the cursor over it while execution is
paused, it shows 2 rectangular symbols before the 1st "FROM". Thinking that
the code was getting a CR-LF that it didn't like, I killed the EOL's in the
original query (from within the database window), but this did not prevent
the error.
Has anyone seen this before? Is it something to do with the length of the
string strSQL?
Thanks!