I have a query with the following SQL statement:
SELECT SUBQ.NEW_TYPE, Sum([QTY]*[QTY1]) AS FQTY
FROM (SELECT IIf(InStr([TYPE],"_")>0,Left([TYPE],InStr([TYPE],"_")-1),[TYPE]) AS NEW_TYPE,QTY,QTY1
FROM [Unit Master]) AS SUBQ
GROUP BY SUBQ.NEW_TYPE;
If I run it and then change to SQL view the code has been changed to:
SELECT SUBQ.NEW_TYPE, Sum([QTY]*[QTY1]) AS FQTY
FROM [SELECT IIf(InStr([TYPE],"_")>0,Left([TYPE],InStr([TYPE],"_")-1),[TYPE]) AS NEW_TYPE,QTY,QTY1
FROM [Unit Master]]. AS SUBQ
GROUP BY SUBQ.NEW_TYPE;
The () have changed to []. in the FROM statement. It still displays the same record set, but I have code in a cmd Click event that uses the REPLACE function to redirect the table source (i.e. Unit Master becomes GrayJob). When I run that code I get a runtime error "improper use of brackets".
Does anyone know why this occurs and how to prevent it?
Thanks in advance.
SELECT SUBQ.NEW_TYPE, Sum([QTY]*[QTY1]) AS FQTY
FROM (SELECT IIf(InStr([TYPE],"_")>0,Left([TYPE],InStr([TYPE],"_")-1),[TYPE]) AS NEW_TYPE,QTY,QTY1
FROM [Unit Master]) AS SUBQ
GROUP BY SUBQ.NEW_TYPE;
If I run it and then change to SQL view the code has been changed to:
SELECT SUBQ.NEW_TYPE, Sum([QTY]*[QTY1]) AS FQTY
FROM [SELECT IIf(InStr([TYPE],"_")>0,Left([TYPE],InStr([TYPE],"_")-1),[TYPE]) AS NEW_TYPE,QTY,QTY1
FROM [Unit Master]]. AS SUBQ
GROUP BY SUBQ.NEW_TYPE;
The () have changed to []. in the FROM statement. It still displays the same record set, but I have code in a cmd Click event that uses the REPLACE function to redirect the table source (i.e. Unit Master becomes GrayJob). When I run that code I get a runtime error "improper use of brackets".
Does anyone know why this occurs and how to prevent it?
Thanks in advance.