I am trying to create an update query that will update a table with a calculated field. Every time I run this, I receive a type conversion failure error. How can I go about this?
The Tables:
Product
Code:
Product Number
FT Headcount Qtr 1
FT Headcount Qtr 2
FT Headcount Qtr 3
FT Headcount Qtr 4
PT Headcount Qtr 1
PT Headcount Qtr 2
PT Headcount Qtr 3
PT Headcount Qtr 4
FT Headcount Avg
Code:
Product Number
FTAvgQtr1
FTAVGQtr2
FTAVGQtr4
PT Headcount Avg
Code:
Product Number
PTAvgQtr1
PTAVGQtr2
PTAVGQtr3
PTAVGQtr4
Where the FT and PT Headcounts are calculated from:
Resources
Code:
Product Number
Qtr1: (nz([Nov],0)+nz([Dec],0)+nz([Jan],0))/3
Qtr2: (nz([Feb],0)+nz([Mar],0)+nz([Apr],0))/3
Qtr3: (nz([May],0)+nz([Jun],0)+nz([Jul],0))/3
Qtr4: (nz([Aug],0)+nz([Sep],0)+nz([Oct],0))/3
The SQL to create the PT and FT Headcounts:
Code:
SELECT Resources.Project_Number, Sum(Resources.Qtr1) AS AvgQtr1, Sum(Resources.Qtr2) AS AvgQtr2, Sum(Resources.Qtr3) AS AvgQtr3, Sum(.Qtr4) AS AvgQtr4
FROM Resources
WHERE (((Resources.Type)="FT"))
GROUP BY Resources.Project_Number;
Code:
SELECT Resources.Project_Number, Sum(Resources.Qtr1) AS AvgQtr1, Sum(Resources.Qtr2) AS AvgQtr2, Sum(Resources.Qtr3) AS AvgQtr3, Sum(.Qtr4) AS AvgQtr4
FROM Resources
WHERE (((Resources.Type)="PT"))
GROUP BY Resources.Project_Number;
What I am trying to do is to update the Product Table to contain the proper Headcounts. For example, Product.[FT Headcount Qtr 1] will contain [FT Headcount Avg].FTAvgQtr1.
My attempt to do this has given me the type conversion failure ( this was a test to see if I could get even one field to update. The error message was the same):
Code:
UPDATE Product
SET Product.[FT Headcount Qtr 1] = DLookUp("FTAvgQtr1","[FT Headcount Avg]","[Product_Number]=" & [Products].[Product_Number]);
How can I create an update statement that will update the data the way that I need?
Thank you for any help you may be able to provide!