Hi All,
Can anyone help me clean up my query so that it doesn't crash access and cause the CPU usage to sky rocket?
I want to simply add together values from a previous line, and it worked fine for one column (though slow) using the dlookup feature. When I did it for another column with dlookup, access crashes...
Can anyone suggest how to accomplish this better?
Can anyone help me clean up my query so that it doesn't crash access and cause the CPU usage to sky rocket?
I want to simply add together values from a previous line, and it worked fine for one column (though slow) using the dlookup feature. When I did it for another column with dlookup, access crashes...
Can anyone suggest how to accomplish this better?
Code:
SELECT AnalysisYears.StudyYears, [Funding Plan Ideal Balances].UnadjustedIdealBalance, [Funding Plan Ideal Balances].InflationAdjustedIdealBalance, [Funding Plan Summary Expenditures].Inflation_Adjusted_Expenditures, [Funding Plan Summary Expenditures].Expr1 AS UnadjustedExpenditures, ReserveParameters.InvestmentRate AS InvestRate, Format([ReserveParameters]![CashFlowStartingContribution]*(1+[ReserveParameters]![InvestmentRate])^([StudyYears]-[ReserveParameters]![StartingBalanceYear]),"Currency") AS AnnualContribution, [InvestRate]*([StartBalance]-[Inflation_Adjusted_Expenditures]/2+[AnnualContribution]/2) AS InterestIncome, IIf([StudyYears]=[ReserveParameters]![StartingBalanceYear],[ReserveParameters]![StartingBalance],DLookUp("[AnnualContribution]","GenerateFundingPlanData","[StudyYears]=" & [StudyYears]-1)+DLookUp("[InterestIncome]","GenerateFundingPlanData","[StudyYears]=" & [StudyYears]-1)) AS StartBalance
FROM ReserveParameters, [Funding Plan Summary Expenditures] INNER JOIN (AnalysisYears INNER JOIN [Funding Plan Ideal Balances] ON AnalysisYears.StudyYears = [Funding Plan Ideal Balances].StudyYears) ON [Funding Plan Summary Expenditures].CEY = AnalysisYears.StudyYears
ORDER BY AnalysisYears.StudyYears;