Access Crashes and Close using Dlookup in form

WineSnob

Not Bright but TENACIOUS
Local time
Today, 08:27
Joined
Aug 9, 2010
Messages
211
I have a form with drop downs for Vendor that returns the budgeted income and actual income. On the form I have a unbound control that uses a query to calculate the pertage of budget to actual income.
=DLookUp("[Percentage]","[qryYTDPercentFinal]") this control works fine if there is a least one value. However if all budget vs income = 0 Access crashes. In some months the value of this control is #error because
0 - 0 = 0 and the dlookup query is trying to divide 0 by 0. I get that but why does it crash?
Here is the field in the query where the dlookup is looking.
Percentage: [Actual]/[Budget]
 
I think I have fixed it by putting and iif statement in the query for the Dlookup.
Percentage: IIf([Actual]=0,0,[Actual]/[Budget])
 

Users who are viewing this thread

Back
Top Bottom