Runtime error 2055 (1 Viewer)

krispetrie

New member
Local time
Today, 19:35
Joined
Apr 12, 2001
Messages
8
I have a form that will feed parameters to a series of reports. In my test mode, I keep getting a runtime error 2055, "The expression "I" you entered is invalid." The code the debug function points to is below:

Function CalcPercent(intNum1, intNum2, Pct)

' Pct indicates how number should be formatted
' "Y" = Format as percent - default 1 decimal place
' "Y2" = Format as percent - 2 decimal places
' "N" = No formattting

If IsNull(intNum2) Or intNum2 = 0 Or IsNull(intNum1) Or intNum1 = 0 Then
If Pct = "Y" Then
CalcPercent = Format(0, "0.0%")
ElseIf Pct = "Y2" Then
CalcPercent = Format(0, "0.00%")
Else
CalcPercent = 0
End If
Else
If Pct = "Y" Then
CalcPercent = Format(intNum1 / intNum2, "0.0%")
ElseIf Pct = "Y2" Then
CalcPercent = Format(intNum1 / intNum2, "0.00%")
Else
CalcPercent = intNum1 / intNum2
End If
End If

End Function
This is costing me a great deal of time and anguish. Any help would be greatly appreciated. T
 

Matthew Snook

NW Salmon Database
Local time
Today, 19:35
Joined
Apr 19, 2001
Messages
133
I'm not good enough to tell by looking where the problem might be. I recently discovered that the "breakpoints" in the debugger are useful even in small blocks of code like this. Go to each "if" line and each of the lines containing a calculation and hit "F9". Now when you run the form it will bring up the code and stop at each highlighted line. You hit "F5" to advance line by line. When you get the error, go back to the last line executed and your search will be narrowed considerably.

Matt
 

Users who are viewing this thread

Top Bottom