Will this formula work in Access (distance between Lat/Long points

G

Guest

I am trying to work on a query that will give me the distance between two
geo-points.

My question is will this formula work 'as is' within Access or do I have to
make some alterations. The formula uses the 'Great Circle Distance'
calculation. I'm not very good at high maths/trig, so was hoping that I could
somehow paste this into a VBA function and use it with adjusted field
references (Lat/Long). I found the formula elsewhere, and it works perfectly
in Excel.

=RadiusEarth*ACOS(COS(RADIANS(90-(Lat1*24)))*COS(RADIANS(90-(Lat2*24)))+SIN(RADIANS(90-(Lat1*24)))*SIN(RADIANS(90-(Lat2*24)))*COS(RADIANS(24*(Long1-Long2))))
 
J

John Nurick

It won't work as it stands. Many Excel worksheet functions don't have
direct counterparts in VBA - including ACOS() and RADIANS().

Here's a VBA function that converts degrees to radians:

Public Function Radians(Degrees As Double) As Double
'Converts an angle expressed in degrees
'to the equivalent in Radians

Radians = Degrees * Atn(1) / 45
End Function

A web search is sure to find one or more VBA functions for ACos().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top