georgesOne
Technical User
I have a query like follows - collecting data for certain years, actually for ten years ahead -
and I wonder, if there is not an easier way to generate such a query. This is currently all hard-coded, but I guess it must - actually should - not be, as next year another year will become active, and the current first year data will be deleted.
Any suggestions?
Thanks, georgesOne
Code:
SELECT qryProjects.ProjectID, qryProjects.Project, qryProjects.Layers, qryProjects.DispenseVolume, Round(DLookUp("WS2010","tblPlateStarts","Project = '" & [Project] & "'")) AS Volume2010, Format(qryProjects.InitialPrice,"Currency") AS Price2010, Format(qryProjects.EstimatedCOGS,"Currency") AS COGS2010, Format([Price2010]*[Volume2010],"Currency") AS Sales2010, Format(1-[COGS2010]/[Price2010],"Percent") AS GM2010,
Round(DLookUp("WS2011","tblPlateStarts","Project = '" & [Project] & "'")) AS Volume2011, DLookUp("PriceCHange","tblDefaultChanges","YearChange = " & 2011) AS PD2011, DLookUp("COGChange","tblDefaultChanges","YearChange = " & 2011) AS CC2011, Format([Price2010]*(1+[PD2011]),"Currency") AS Price2011, Format([COGS2010]*(1+[CC2011]),"Currency") AS COGS2011, Format([Price2011]*[Volume2011],"Currency") AS Sales2011, Format(1-[COGS2011]/[Price2011],"Percent") AS GM2011,
Round(DLookUp("WS2012","tblPlateStarts","Project = '" & [Project] & "'")) AS Volume2012, DLookUp("PriceChange","tblDefaultChanges","YearChange = " & 2012) AS PD2012, DLookUp("COGChange","tblDefaultChanges","YearChange = " & 2012) AS CC2012, Format([Price2011]*(1+[PD2012]),"Currency") AS Price2012, Format([COGS2011]*(1+[CC2012]),"Currency") AS COGS2012, Format([Price2012]*[Volume2012],"Currency") AS Sales2012, Format(1-[COGS2012]/[Price2012],"Percent") AS GM2012,
......
FROM qryProjects;
and I wonder, if there is not an easier way to generate such a query. This is currently all hard-coded, but I guess it must - actually should - not be, as next year another year will become active, and the current first year data will be deleted.
Any suggestions?
Thanks, georgesOne