I would be grateful for some help, please, in understanding why the below query returns the "Operation must use an updateable query" message:
UPDATE QC_Costs
SET QC_Costs.No_Makes = (SELECT Count(Temp_Tbl.Unique_ID) AS MakesCount
FROM (SELECT GSR.Unique_ID,
GSR.Month_Name,
GSR.Year_No
FROM GSR
INNER JOIN Products
ON Products.Unique_ID = GSR.Product_ID
WHERE ( ( ( Products.Item_category ) = "MAKE" )
AND ( ( GSR.Transaction_Type ) = "Invoice" ) )) AS Temp_Tbl
WHERE ( ( ( Temp_Tbl.Month_Name ) = QC_Costs.Month_Name )
AND ( ( Temp_Tbl.Year_No ) = QC_Costs.Year_No ) ));
I have read numerous articles that this message appears when permissions to update the database are not set correctly. I have tried to make those changes to the folder permissions (although everything already looked fine), and what I don't fully understand is if I write a different query where I simply want to make the No_Makes field in the QC_Costs table a 1, the query runs fine. This leads me to believe the issue is in my count query or sub-query, but when I turn this section of the query into a SELECT query and run it on its own it returns a result.
I am not an expert at all - I have only tried to work with sub-queries today for the first time - so I would really appreciate some help.
For context - I have a table full of invoices and credit notes (the GSR). Another table called Products contains a list of products that has an Item_Category field. The GSR is linked to Products via a Product_ID field. A third table called QC_Costs has a record for each month and a field called No_Makes. I want to capture the number of invoices for MAKE products for a given month in the GSR and update the No_Makes field in the QC_Costs table with that number. This number will be used in another query I am yet to write or may add to this one where an amount of costs is divided by No_Makes and then this value is posted back into the GSR against each of these records.
I hope the above makes sense - please let me know if I need to provide anything further.
Thank you
EDIT:
In response to Parfait's answers I have written the following and it runs - thank you:
UPDATE QC_Costs
SET QC_Costs.QC_Cost_Allocation =
DLookup("SumOfQC_Costs_To_Allocate", "Sum_Of_QC_Costs","Month_Name = " & [QC_Costs].[Month_Name] & " AND Year_No = " & [QC_Costs].[Year_No]) /
DLookUp("CountofUniqueID","Count_Of_Makes","Month_Name = " & [QC_Costs].[Month_Name] & " AND Year_No = " & [QC_Costs].[Year_No]);
I am really close but I get a message for every record where this will execute that there is a type conversion failure. The data type of the destination field is Double, and I have made sure the denominator Dlookup query isn't a zero so the answer to this division should be a numeric decimal, so can anyone explain to me how to troubleshoot what's wrong, please?
I'm now off the question topic so I apologise for that - please let me know if I have to repost as a new question.
Thanks