Hi,

I how can I calculate distance between 2 points. I have created a table with the name of towns, post codes and coordinates.

The table look like this:

Town/Site Post Code Longitude Latitude

Moranbah 4740 148.04577 -22.00091

I would like to use the table to give me the distance between the 2 points in Km's.

So If I created 2 combo box's To: and From: a Message Box would appear and say the distance between i.e Moranbah and Dysart is 60.271Km.

Is this possible to do using MS Access 07?

If so where do I begin?

Many Thanks

Serina

I how can I calculate distance between 2 points. I have created a table with the name of towns, post codes and coordinates.

The table look like this:

Town/Site Post Code Longitude Latitude

Moranbah 4740 148.04577 -22.00091

I would like to use the table to give me the distance between the 2 points in Km's.

So If I created 2 combo box's To: and From: a Message Box would appear and say the distance between i.e Moranbah and Dysart is 60.271Km.

Is this possible to do using MS Access 07?

If so where do I begin?

Many Thanks

Serina

c = 2.atan2(va, v(1-a))

d = R.c

where R is earth’s radius (mean radius = 6,371km);

note that angles need to be in radians to pass to trig functions!

javaScript :

var R = 6371; // km

var dLat = (lat2-lat1).toRad();

var dLon = (lon2-lon1).toRad();

var lat1 = lat1.toRad();

var lat2 = lat2.toRad();

var a = Math.sin(dLat/2) * Math.sin(dLat/2) +

Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);

var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

var d = R * c;

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

If you have MapPoint available to you, your task can utilize automation of MapPoint. Using MapPoint from Word, Access and Excel

----

If you do not have MapPoint available to you, then something like this should do the trick. I did not write this, as far as I know it came from here (note the version, Access 95) -- I just pasted it in a module if I ever needed it again :)

Open in new window

You will need to know the radius of the Earth -- unfortunately I have never used this code, so I cannot atest to its usability or accuracy -- but it looked cool, so I kept it :)