How to code this math

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Access 2003


=ACOS(SIN([Lat1])*SIN([Lat2])+COS([Lat1])*COS([Lat2])*COS([Lon2]-[Lon1]))*6371

Where Lat1, Lon1, Lat2, Lon2 are values in a table (So they will be fields)

Is this math that Access can do?

Is it as simple as dropping the formula in the control source?

Any pointers here would be much appreciated.

tx
Dave
 
The basic trig. functions are built into VBA, but not ACos().

You could add something like this:
Function ArcCos(X As Double) As Double
' Inverse Cosine
If X = 1 Then
ArcCos = 0
ElseIf X = -1 Then
ArcCos = -PI()
Else
ArcCos = Atn(X / Sqr(-X * X + 1)) + PI() / 2
End If
End Function

That comes from a sample database MS released back in 1995, called
neatcode.mdb:
http://support.microsoft.com/kb/148402
There was a more recent version, but I don't have the link.
That database also has a module for Latitude/Longitude - particularly useful
for converting units and calculating GreatArcDistance().
 
Thanks very much.

Your code will help - but I am hoping the L/L moduial will be what I am
needing already.

dave
 
Back
Top