Sorry. No. Not a custom expression, a custom Function. In a general
module, create a function that looks like this:
Function Arccos(X as Double) As Double
Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function
Then use YOUR Arccos exactly like you would use the ACOS.
Expr1
3958.755866*Arccos((Cos((90-[y])*PI()/180)*Cos((90-[lat1])*PI()/180)+
Sin((90-[y])*PI()/180)*Sin((90-[y])*PI()/180)*Cos(([x]-[lon1])*PI()/180))))
Given that PI doesn't exist either (I didn't realise that), you will want to
create a Constant in Access too. In the same module (NOT in the function.
At the top of the MODULE) put:
Const PI As Double = 3.1416 (to whatever precision you want.)
You can also get rid of the parens after PI in your expression.
--
--Roger Carlson
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
Thanks, thats what i figured the problem was after i got the same error
for
"pi". your response, however, raises a second question. how do i create a
custom expression. do you mean, create the expression defining 'acos'
first
and then create the second expression referencing the result of the 'acos'
expression for "acos"?
:
Access 2000 Help is blindly unhelpful here. It appears that ACOS is
supported, but it is not. It is actually giving Help for Excel, which
you
don't need.
Since Access does not support ACOS, you will have to derive it.
According
to Access 97 Help (which IS helpful), you can derive it by the following
formula:
Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
I suggest you create a custom function called Arccos() that will
calculate
it and return it to the Expression.
BTW, here are some other helpful derived functions from Access 97 Help:
Secant Sec(X) = 1 / Cos(X)
Cosecant Cosec(X) = 1 / Sin(X)
Cotangent Cotan(X) = 1 / Tan(X)
Inverse Sine Arcsin(X) = Atn(X / Sqr(-X * X + 1))
Inverse Cosine Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
Inverse Secant Arcsec(X) = Atn(X / Sqr(X * X - 1)) + Sgn((X) - 1) * (2 *
Atn(1))
Inverse Cosecant Arccosec(X) = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) *
(2 *
Atn(1))
Inverse Cotangent Arccotan(X) = Atn(X) + 2 * Atn(1)
Hyperbolic Sine HSin(X) = (Exp(X) - Exp(-X)) / 2
Hyperbolic Cosine HCos(X) = (Exp(X) + Exp(-X)) / 2
Hyperbolic Tangent HTan(X) = (Exp(X) - Exp(-X)) / (Exp(X) + Exp(-X))
Hyperbolic Secant HSec(X) = 2 / (Exp(X) + Exp(-X))
Hyperbolic Cosecant HCosec(X) = 2 / (Exp(X) - Exp(-X))
Hyperbolic Cotangent HCotan(X) = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X))
Inverse Hyperbolic Sine HArcsin(X) = Log(X + Sqr(X * X + 1))
Inverse Hyperbolic Cosine HArccos(X) = Log(X + Sqr(X * X - 1))
Inverse Hyperbolic Tangent HArctan(X) = Log((1 + X) / (1 - X)) / 2
Inverse Hyperbolic Secant HArcsec(X) = Log((Sqr(-X * X + 1) + 1) / X)
Inverse Hyperbolic Cosecant HArccosec(X) = Log((Sgn(X) * Sqr(X * X + 1)
+ 1)
/ X)
Inverse Hyperbolic Cotangent HArccotan(X) = Log((X + 1) / (X - 1)) / 2
Logarithm to base N LogN(X) = Log(X) / Log(N)
--
--Roger Carlson
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
i'm having a problem performing the following expression in an access
(2000)
query that seems to work just fine in excel (2003). I get the error
in
the
suject header.
Expr1:
(3958.755866*ACOS((Cos((90-[y])*PI()/180)*Cos((90-[lat1])*PI()/180)+Sin((90-
[y])*PI()/180)*Sin((90-[y])*PI()/180)*Cos(([x]-[lon1])*PI()/180))))
any suggestions are helpful
thanks