Writers' Community!
Home Page Two Columnists Q&A Submit an Article FAQs Contact Author Login
Article Submission
We Need YOUR Articles!
We'll Promote Them for FREE!

Author Login

New Authors
Register Here


Now Serving 7,757 Authors
70,408 Quality Articles
& 3,032 Current Users Online!
Featured Authors
Fran Larson (2,271)
Joel Hendon (16,285)
Shari Vaudo (418)
David Tanguay (9,577)
Michael Ramzy (633)
Missing Link (766)
E. Raymond Rock (3,068)
Gregory Lewis (1,603)
Nancy Daniels (1,550)
Mark Parsec (15,056)
Sandra E. Graham (7,883)
David Pekrul (3,696)
Ira Coffin (6,669)
Julian Price (3,951)

View All Featured Authors
Most Recent
How to Remove the Vocals from a Song

Jazz Up and Organize Your Inbox with Color Categories

Preventing Malware While Browsing The Internet

Should A Cad Come With The Operation System?

Should A Cad Come With The Operation System?

How To Setup An Email Out of Office Auto Reply In Mircosoft Outlook

How can I open a 2007 Microsoft Office file in an earlier version of Office?

What are the Key Requirements for Privacy Control Software?

Wny Do You Need Open Source Audits

No Programming Web Design

Home » Categories » Computers & Networking » Software » How to Build a Simple Distance Checker between 2 UK Postcodes into Your Access Database » Reprint Rights » Printer Friendly

How to Build a Simple Distance Checker between 2 UK Postcodes into Your Access Database

Rated 3.5 out of 5
Rated 3.6 by 1 Reader ?
Rate It  /  View Comments  /  View All Articles submitted by Michael Jillions
Submitted Friday, May 29, 2009
Michael Jillions (183)
Mill House Data Solutions Ltd
Log in to become a member of Michael Jillions's Fan Club!


Being able to determine the distance between two places is of an enormous benefit in many software applications. There are simply hundreds of uses and we at Mill House Data Solutions have used it to great effect many, many times. There are online companies who can offer, for a subscription, automated access to their distance check software but this will not only cost, but will rely on internet access as well.

This method will only calculate the distance in Kilometres (divide the result by 1.609344 for miles) "as the crow files" but it is extremely useful when, for instance, you are marketing everyone within a fixed radius.

So how do we do it? The method uses the "Haversine" formula which assumes that the Earth is a sphere. OK we know that the Earth is not a perfect sphere, but when you are checking between two map co-ordinates it is more than accurate enough for these purposes.

OK so without going into the technicalities of how the formula works, we shall get straight on with the coding requirements for VBA.

You will need a table in your application containing all the UK postcode variations and the X & Y axis co-ordinates. We would be very happy to provide a copy.

The following VBA Code attached to the "Calculate Distance" click event is used in a simple form where the user enters the start and end postcodes and the distance is calculated.

txtPostCodeStart and txtPostCodeEnd are blank text boxes for entering your criteria.

txtStartLat, txtEndLat, txtStartLong and txtEndLong are text boxes that are automatically populated through the"after update" event on the text boxes "txtPostCodeStart" and "txtPostCodeEnd" using simple RecordSet vba programming.

Private Sub caldistance_Click()

On Error GoTo Err_caldistance_Click

If Me.TxtPostCodeStart = "" Then

MsgBox ("Please enter a Start Post Code")

Exit Sub

End If

If Me.TxtPostCodeEnd = "" Then

MsgBox ("Please enter an End Post Code")

Exit Sub

End If

Distance = (Sin((Me.TxtEndLat * 3.14159265358979) / 180)) * (Sin((Me.TxtStartLat * _

3.14159265358979) / 180)) + (Cos((Me.TxtEndLat * 3.14159265358979) / 180)) * _

((Cos((Me.TxtStartLat * 3.14159265358979) / 180))) * _

(Cos((Me.TxtStartLong - Me.TxtEndLong) * (3.14159265358979 / 180)))

Distance = 6371 * (Atn(-Distance / Sqr(-Distance * Distance + 1)) + 2 * Atn(1))

Me.TxTDistance = Distance

Exit_caldistance_Click:

Exit Sub

Err_caldistance_Click:

MsgBox Err.Description

Resume Exit_caldistance_Click

End Sub

Whilst we have demonstrated a simple form, the basic formula is there to be used in a host of different ways. We hope you will find this as useful as we have!




The author of this article has chosen to make this article available with free reprint rights.
Click here to copy this article.

Reprint Rights

Log in to become a member of Michael Jillions's Fan Club!

Comments on this article: (1 total)


» left by jena (440)
jena
(143 days 5 hours ago.)

Reader Rating: 3 out of 5
Ummmmmm....very interesting!

Respond to this comment

Was this article helpful to you? Leave a Public Comment or Question:

This Article has been viewed 53 times.
Article added to SearchWarp.com on 5/29/2009 5:07:31 AM.
View other articles written by Michael Jillions (183)


If you found this article interesting, you may want to check out:

Disclaimer:  All information on this site is provided for informational purposes only! By no means is any information presented herein intended to substitute for the advice provided to you by any health care or other professional or organization.


Today's Most Popular
Improve PC Performance - 6 Tips You Must Know.

Introduction to DQL-Documentum Query Language

Linux Command Tutorials - Opening a Linux Terminal / Console to Run Linux Commands - Tutorial Help

Linux Commands Tutorials - Using the ls Command with Examples of Options - A Hands-On Tutorial Help

Software Development Lifecycle (SDLC) - Overall Project Measurement

What Shows Up On a Criminal Record Background Check?

Multiversion Concurrency Control (MVCC)- How PostgreSQL attain data consistency

Elimination of Spooler Subsystem App problem. Easy and quick.

FTPS (FTP over SSL) vs. SFTP (SSH File Transfer Protocol): What To Choose

Microsoft Word 2000 Tips – How To Add Web Hyperlinks to a Document

Viewed from Cache. Load Time: 0.016.

Home  |  Page Two  |  FAQ's  |  Contact  |  Terms of Service  |  Article Submission Guidelines  |  Questions & Answers  |  Privacy  |  Mission / About
Copyright © 1999-2009 SearchWarp.com, All Rights Reserved - SearchWarp.com is an IcoLogic, Inc. Company