Hello Ryan
I think I have the formulae for you. I made a mistake in the previous calculation of the 'LastDepnDate' value. Use this calculation instead :
LastDepnDate: IIf(IsNull([Sale_Date]), DateAdd("m", [MonthsToGo], IIf([Purch_Date]<#30/09/2005#, #30/09/2005#, [Purch_Date])), IIf([Sale_Date] > DateAdd("m", [MonthsToGo], IIf([Purch_Date] < #30/09/2005#, #30/09/2005#, [Purch_Date])), DateAdd("m", [MonthsToGo], IIf([Purch_Date] < #30/09/2005#, #30/09/2005#, [Purch_Date])), DateAdd("d", -Day([Sale_Date]), [Sale_Date])))
For the opening depreciation value, use this:
OpeningDepn: IIf([Purch_Date] > [LastYearEnd], 0, IIf([Sale_Date] <= [LastYearEnd], 0, IIf([LastDepnDate] <= [LastYearEnd], [Purch_Cost], IIf([Purch_Date] < #30/09/2005#, [30SepAccDepn] + ([MonthlyDepn] * DateDiff("m", #30/09/2005#, [LastYearEnd])), [MonthlyDepn] * (0.5 + DateDiff("m", [Purch_Date], [LastYearEnd]))))))
For the month to date depreciation charge, use this:
MonthDepnCharge: IIf([Purch_Date] > [MonthEnd] Or [LastDepnDate] < [MonthEnd], 0, IIf([Purch_Date] <= DateAdd("d", -Day([MonthEnd]), [MonthEnd]) And [LastDepnDate] > [MonthEnd], [MonthlyDepn], Int(([MonthlyDepn] * 50) +0.5)/100)) + IIf([Purch_Date] <= DateAdd("d", -Day([MonthEnd]), [MonthEnd]) And IsNull([Sale_Date]) And [LastDepnDate] <= [MonthEnd] And [LastDepnDate] > DateAdd("d", -Day([MonthEnd]), [MonthEnd]), [Purch_Cost] - nz([30SepAccDepn]) - (([MonthsToGo]-1) * [MonthlyDepn]),0)
For the year to date depreciation, use this:
YTDDepn: [MonthDepnCharge] + IIf([Purch_Date] > DateAdd("d", -Day([MonthEnd]), [MonthEnd]) Or [LastDepnDate] <= [LastYearEnd], 0, IIf([LastDepnDate] > DateAdd("d", -Day([MonthEnd]), [MonthEnd]), IIf([Purch_Date] <= [LastYearEnd], [MonthlyDepn] * DateDiff("m", DateAdd("d", 1, [LastYearEnd]), DateAdd("d", 1-Day([MonthEnd]), [MonthEnd])), [MonthlyDepn] * (0.5+DateDiff("m", [Purch_Date], DateAdd("d", -Day([MonthEnd]), [MonthEnd])))), IIf([Purch_Date] <= [LastYearEnd], IIf(IsNull([Sale_Date]), [Purch_Cost]-[OpeningDepn], [MonthlyDepn] * DateDiff("m", [LastYearEnd], [LastDepnDate])), IIf(IsNull([Sale_Date]), [Purch_Cost], IIf(Month([Sale_Date]) = Month([Purch_Date]), 0, [MonthlyDepn] * (0.5+DateDiff("m", [Purch_Date], DateAdd("d", -Day([Sale_Date]), [Sale_Date]))))))))
For the depreciation to reverse on the sale of an asset, use this:
SalesDepn: IIf(IsNull([Sale_Date]), 0, IIf([Sale_Date] > [LastYearEnd] And [Sale_Date] <= [MonthEnd], -Nz([OpeningDepn])-Nz([YTDDepn]),0))
And the accumulated depreciation is this:
AccumDepn: [OpeningDepn] + [YTDDepn] + [SalesDepn]
These calculations have been designed for any month or 30 Sep year end in mind (post 2005), and they incorporate the calculations I previously supplied. Please note the 'last depreciation date' calculation has been changed (see above).
If you end up with a 'too complex' error then you may need to split the cost and depreciation calculations into 2 different queries.
HTH, Andrew