message
i know how to do it by vb code but its working from queries? any way still
I
am not able to find ATAN2 ? i have got it as function, but when Iam
calling
it from Queries its not working?
Option Compare Database
Function atan2(ys, xs)
' Given y and x coords returns atan2
' by Jim Deutch, Syracuse, New York
Dim theta, pi
pi = 3.14159265358979
If xs <> 0 Then
theta = Atn(ys / xs)
If xs < 0 Then
theta = theta + pi
End If
Else
If ys < 0 Then
theta = 3 * pi / 2 '90
Else
theta = pi / 2 '270
End If
End If
atan2 = theta
End Function
First make sure the function is public, not private. If I remember rightly
(and I am going from memory here so I could be wrong) I think when you dont'
specify public or private, the function is public by default if declared in
a standard module but private by default if declared in a class module such
as a form or report module. So make sure your function is in a standard
module. Its probably good practice to explicitly declare it as public any
way ...
Public Function atan2(ys, xs)
... and please, please, please use Option Explict, not using it is a
guaranteed way to cause endless problems for yourself and anyone else who
has to deal with your code ...
Option Compare Database
Option Explicit
Public Function atan2(ys, xs)
If the function is public, you shouldn't have any difficulty calling it from
a query. If you're sure it's public and you still can't call it from a
query, someone will probably be able to tell you what the problem is if you
post the SQL.