Help! Something wacky is going on with the query sql editor. I write a query, save it, run it. It runs fine (doesn't give me the results that I expect, but that's because I'm probably doing something wrong with the functions I'm using- but that's my own problem and I know it). Then, if I close the database and later reopen it and come back to edit the query I get an error saying that it can't find the table '...' (part of the FROM clause here). When I open in SQL view, I see that the internal Access sql editor, or whatever this evil function is called, has put square brackets and a semicolon where I had parentheses brackets- and it ERASED a whole chunk of the select statement in my subquery!!!
Can anyone help me to understand why this is happening? I don't think my database is corrupt- I am in the designing stages and am the only one accessing it, and I barely have any data in it. I ran a Office repair from Control Panel, but that's not helping. I still get the error on reopening the database. (Note: the error doesn't always occur when I just close the database- sometimes my changes stick and Access doesn't mess with my query syntax when I close the application- but it ALWAYS happens after I restart the computer).
The sql is below. I would really appreciate any feedback on this. Thank you!
My original query:
This is what Access changes it to:
Can anyone help me to understand why this is happening? I don't think my database is corrupt- I am in the designing stages and am the only one accessing it, and I barely have any data in it. I ran a Office repair from Control Panel, but that's not helping. I still get the error on reopening the database. (Note: the error doesn't always occur when I just close the database- sometimes my changes stick and Access doesn't mess with my query syntax when I close the application- but it ALWAYS happens after I restart the computer).
The sql is below. I would really appreciate any feedback on this. Thank you!
My original query:
PHP:
SELECT V.VendorName, Sum(V.CurrentBudget) AS SumOfCurrentBudget, [SpentCurrentFY - ClosedCurrentFY] AS OpenCurrentFY, [SpentPrev - ClosedPrev] AS OpenPrev
FROM
(SELECT VendorName, sum(Current_FY_Budget) AS CurrentBudget FROM Vendors GROUP BY VendorName) AS V
INNER JOIN
(SELECT VendorName,
sum(IIf(BHSRequisitionNum Like '2012*',POAmountActual,0)) AS SpentCurrentFY,
sum(IIf(BHSRequisitionNum Like '2012*',ClosedAmount,0)) AS ClosedCurrentFY,
sum(IIf(BHSRequisitionNum Not Like '2012*',POAmountActual,0)) AS SpentPrev
FROM PurchaseOrders group by VendorName) AS P
ON V.VendorName=P.VendorName
GROUP BY V.VendorName;
This is what Access changes it to:
PHP:
SELECT V.VendorName, Sum(V.CurrentBudget) AS SumOfCurrentBudget, [SpentCurrentFY - ClosedCurrentFY] AS OpenCurrentFY, [SpentPrev - ClosedPrev] AS OpenPrev
FROM [SELECT VendorName, sum(Current_FY_Budget) AS CurrentBudget FROM Vendors GROUP BY VendorName;] AS V INNER JOIN [SELECT VendorName, sum(IIf(BHSRequisitionNum Like '2012*',POAmountActual,0)) AS SpentCurrentFY, sum(IIf(BHSRequisitionNum Like '2012*',ClosedAmount,0)) AS ClosedCurrentFY, sum(IIf(BHSRequisitionNum Not Like '2012*',POAmountActual,0)) AS SpentPrev FROM Pu]. AS P ON V.VendorName=P.VendorName
GROUP BY V.VendorName;