MeldrethMan
Technical User
I'm calling this function from a form but am getting a type mismatch error. It works fine in the Immediate window eg ?Points(8,11,5,5) returns 2.
Code:
Public Function Points(ShotAllowance As Byte, SI As Byte, Score As Byte, Par As Byte)
Dim Diff As Byte
Dim Netscore As Byte
If ShotAllowance > 18 Then
Netscore = IIf(SI > (ShotAllowance - 18), Score - 1, Score - 2)
Else
Netscore = IIf(SI > ShotAllowance, Score - 0, Score - 1)
End If
Diff = Netscore - Par
If Diff = -3 Then Points = 5
If Diff = -2 Then Points = 4
If Diff = -1 Then Points = 3
If Diff = 0 Then Points = 2
If Diff = 1 Then Points = 1
If Diff > 1 Then Points = 0
End Function
The subform contains the command button that calls the function, and two of its parameters. The other two parameters are in the frmComps. This is one of the calls, where Points1 is type Number/Byte
Code:
Points1 = Points(ShotAllowance, [Forms]![frmComps].SI1, Score1, [Forms]![frmComps].[Par1])
I also get the error if using a test set of numbers as parameters instead of these references.
Any thoughts?