krispetrie
New member
- Local time
- Today, 20:32
- 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
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