Question : If a field is blank I need it let other calculations after it work in a form.   I know that its something to do with a null.

Here is my layout
Purchase Price
Loan amount
Load Date
Loan End Date
Interest
Expense (in sub form that totals with =Sum([Expense])
Sell price
Days of loan =DateDiff("d",[LoanDate],[LoanEndDate])
Interest to date =Val(LoanAmount.Value)*Val(InterestRate.Value)*Val(Text99.Value)
Total Expenses =[Expenses Sub Form].Form!Text10
Trade Allowance
Total Investment =Val(PurchasePrice.Value)+Val([Expenses Sub Form].Form!Text10)+Val(Form!InterestToDate)
Profit =Val(SellPrice.Value)-Val(TotalInvestment.Value)-Val(TradeAllowance.Value)

So the way I have it now if I leave loan date, loan end date, interest or a expense all have no input the calculation field shows #Error. I need those fields to be blank or zero if there is no input, but once you put a purchase price in Total investment and profit should calculate ( be if it has not been sold it would be a number that would in parentheses)


Answer : If a field is blank I need it let other calculations after it work in a form.   I know that its something to do with a null.

Access has a built-in Nz function

Nz(Value, ValueIfNull)

Days of loan = DateDiff("d",Nz([LoanDate],0),Nz([LoanEndDate],0))

OM Gang
Random Solutions  
 
programming4us programming4us