I have a recursive function which works (ie I have stepped through it on multiple occasions and never seen it go into an infinite loop and the output is correct) but whenever I use it to validate user input, my code in the BeforeUpdate and AfterUpdate events will never be executed. I have isolated it to the recursion by commenting out the recursive call inside the function and having that call return a static value. Once this happens, all of the code in the other events is executed. I can achieve the same results by taking the user's input string and parsing it character by character so this isn't really a pressing question but its bothering me and I want to know if anyone else has seen a case where recursion has kept events from firing?
<Code>
Private Function FormatCurrencyResponse(strText As String, intCnt As Integer) As String
Dim NumCommas As Integer
Dim strCurrent As String
intCnt = intCnt + 1
Debug.Print intCnt
strCurrent = strText
strCurrent = Replace(strCurrent, ",", "")
strCurrent = Replace(strCurrent, "$", "")
While Left(strCurrent, 1) = "0"
strCurrent = Right(strCurrent, Len(strCurrent) - 1)
Wend
NumCommas = Left(Round(Len(strCurrent), 2), 1)
If NumCommas > 0 And Len(strCurrent) > 3 Then
strCurrent = FormatCurrencyResponse(Left(strCurrent, Len(strCurrent) - 3), intCnt) & "," & Right(strCurrent, 3)
End If
FormatCurrencyResponse = strCurrent
End Function
</code>
<Code>
Private Function FormatCurrencyResponse(strText As String, intCnt As Integer) As String
Dim NumCommas As Integer
Dim strCurrent As String
intCnt = intCnt + 1
Debug.Print intCnt
strCurrent = strText
strCurrent = Replace(strCurrent, ",", "")
strCurrent = Replace(strCurrent, "$", "")
While Left(strCurrent, 1) = "0"
strCurrent = Right(strCurrent, Len(strCurrent) - 1)
Wend
NumCommas = Left(Round(Len(strCurrent), 2), 1)
If NumCommas > 0 And Len(strCurrent) > 3 Then
strCurrent = FormatCurrencyResponse(Left(strCurrent, Len(strCurrent) - 3), intCnt) & "," & Right(strCurrent, 3)
End If
FormatCurrencyResponse = strCurrent
End Function
</code>