Hi Guys,
I'm hoping you can help me here ... I know a bit about Access, but not enough to be efficient yet!! I have a module with the following function to calculate arcCOS value. The only trouble is, on certain records used in the query, it pulls up a "Division by zero" error on the code. Is there any way I can prevent this from happening? Here's the code I'm using:
Public Function ArcCOS(ByVal nValue As Double, Optional fRadians As Boolean = True) As Double
Const PI As Double = 3.14159265359
ArcCOS = -Atn(nValue / Sqr(1 - nValue * nValue)) + PI / 2
If fRadians = False Then ArcCOS = ArcCOS * (PI / 180)
End Function
I'm hoping you can help me here ... I know a bit about Access, but not enough to be efficient yet!! I have a module with the following function to calculate arcCOS value. The only trouble is, on certain records used in the query, it pulls up a "Division by zero" error on the code. Is there any way I can prevent this from happening? Here's the code I'm using:
Public Function ArcCOS(ByVal nValue As Double, Optional fRadians As Boolean = True) As Double
Const PI As Double = 3.14159265359
ArcCOS = -Atn(nValue / Sqr(1 - nValue * nValue)) + PI / 2
If fRadians = False Then ArcCOS = ArcCOS * (PI / 180)
End Function