Using CheckBox Value in Function

WineSnob

Not Bright but TENACIOUS
Local time
Today, 08:53
Joined
Aug 9, 2010
Messages
211
I have a function:
Public Function fnCalcIncome(nYear As Integer, ClientMonthlyInc As Currency, InflationFactor As Double, xTaxchk As Double, yTaxRate As Double) As Currency
Dim I As Integer
Dim IncludeInfl As Integer


For I = 1 To nYear
If I = 1 Then
StartIncomeAmt = ClientMonthlyInc

ElseIf xTaxchk = 1 And InflationFactor > 0 Then
StartIncomeAmt = ((ClientMonthlyInc * (1 + InflationFactor) ^ (I - 1))) * yTaxRate + ((ClientMonthlyInc * (1 + InflationFactor) ^ (I - 1)))

Else

StartIncomeAmt = (ClientMonthlyInc * (1 + InflationFactor) ^ (I - 1))
End If


fnCalcIncome = StartIncomeAmt

Next I



End Function

It works correctly when I test it inVB Editor with 1 being the CheckBox value.
Function testincome()
Debug.Print fnCalcIncome(5, 12000, 0.03, 1, 0.25)
End Function
Result = 15450 CORRECT

However when I use the function in a query it doesn't work. Here is the query.
AssetNeedSeg1Year2: fnCalcIncome(2,[FVMonthlyIncome],[InflationFactor],[IncludeTaxes],0.25)

Result = 12360

When I replace [IncludeTaxes] with 1 it works.
AssetNeedSeg1Year2: fnCalcIncome(2,[FVMonthlyIncome],[InflationFactor],1,0.25)

The question is what is the value of the checkbox when checked? In the table the IncludeTaxes field is a Yes/No.
 
I searched everywhere for that simple answer. It works perfectly!
Thanks..... It is something i will NEVER forget.
 

Users who are viewing this thread

Back
Top Bottom