Hi,
I have encountered a problem and was wondering if anyone has come across one similar.
I have a query running a function called GetYesNoScore (See below) with various parameters. It is a function to see if a field is a “1” and if so, count up the weighting.
So, if I run, GetYesNoScore(2,0.2,1,0.3,1,0.5), I should get a score of 0.8. This is because it finds a 1, then adds the weight to the score. Eg, 0.3 + 0.5 = 0.8.
This all works fine but when the number is shown in the query, it comes up as 0.800000011920929. Even when running through the code and doing a mouse-over, the score comes up as 0.8 but access seems to be losing accuracy when sending the information back to the query.
Does anyone have any advice on the matter?
Thanks for reading this.
Public Function GetYesNoScore(Q1 As Integer, W1 As Single, Optional Q2 As Integer, Optional W2 As Single, Optional Q3 As Integer, Optional W3 As Single, Optional Q4 As Integer, Optional W4 As Single) As Single
Dim score As Single
score = 0
If Q1 = 1 Then
score = score + W1
End If
If Q2 = 1 Then
score = score + W2
End If
If Q3 = 1 Then
score = score + W3
End If
If Q4 = 1 Then
score = score + W4
End If
GetYesNoScore = score
endif
I have encountered a problem and was wondering if anyone has come across one similar.
I have a query running a function called GetYesNoScore (See below) with various parameters. It is a function to see if a field is a “1” and if so, count up the weighting.
So, if I run, GetYesNoScore(2,0.2,1,0.3,1,0.5), I should get a score of 0.8. This is because it finds a 1, then adds the weight to the score. Eg, 0.3 + 0.5 = 0.8.
This all works fine but when the number is shown in the query, it comes up as 0.800000011920929. Even when running through the code and doing a mouse-over, the score comes up as 0.8 but access seems to be losing accuracy when sending the information back to the query.
Does anyone have any advice on the matter?
Thanks for reading this.
Public Function GetYesNoScore(Q1 As Integer, W1 As Single, Optional Q2 As Integer, Optional W2 As Single, Optional Q3 As Integer, Optional W3 As Single, Optional Q4 As Integer, Optional W4 As Single) As Single
Dim score As Single
score = 0
If Q1 = 1 Then
score = score + W1
End If
If Q2 = 1 Then
score = score + W2
End If
If Q3 = 1 Then
score = score + W3
End If
If Q4 = 1 Then
score = score + W4
End If
GetYesNoScore = score
endif