WineSnob
Not Bright but TENACIOUS
- Local time
- Today, 13:00
- Joined
- Aug 9, 2010
- Messages
- 211
I HATE NULL - How do I deal with a null value in a function that requires the argument? I want the function to run even if any of the arguments are null. I am using the function in several queries. Below is an example of the the query. Here is the function:
Public Function fnCalcIncome(nYear As Integer, ClientMonthlyInc As Currency, InflationFactor As Double) As Currency
Dim I As Integer
Dim IncludeInfl As Integer
For I = 1 To nYear
If I = 1 Then
StartIncomeAmt = ClientMonthlyInc
Else
StartIncomeAmt = (ClientMonthlyInc * (1 + InflationFactor) ^ (I - 1))
End If
fnCalcIncome = StartIncomeAmt
Next I
End Function
___________________________________________________________
Here is a field in the query where I need to use the function if as an Example [External2Amt] is null
ExtIncSeg1Y1: fnCalcIncome(1,[External1Amt],[External1InflFactor])+fnCalcIncome(1,[External2Amt],[External2InflFactor])
Public Function fnCalcIncome(nYear As Integer, ClientMonthlyInc As Currency, InflationFactor As Double) As Currency
Dim I As Integer
Dim IncludeInfl As Integer
For I = 1 To nYear
If I = 1 Then
StartIncomeAmt = ClientMonthlyInc
Else
StartIncomeAmt = (ClientMonthlyInc * (1 + InflationFactor) ^ (I - 1))
End If
fnCalcIncome = StartIncomeAmt
Next I
End Function
___________________________________________________________
Here is a field in the query where I need to use the function if as an Example [External2Amt] is null
ExtIncSeg1Y1: fnCalcIncome(1,[External1Amt],[External1InflFactor])+fnCalcIncome(1,[External2Amt],[External2InflFactor])