wnicole,
If you only want to use Access, you would require the following:
- Each lead must have a stored address, latitude, and longitude
- Any new lead must be entered with all 3 as well
If you are able to do the above, then you can create a user-defined function that uses the Haversine formula to find the distances. For example, you can create a VBA Module and then have in it code that looks something like this
Code:
Public Function Haversine(OrigLat as Double, OrigLong as Double, DestLat as Double, DestLong as Double) as Double
Dim pi as Double, AsinBase as Double
pi = 4 * Atn(1)
OrigLat = (OrigLat / 180) * Pi
DestLat = (DestLat / 180) * Pi
OrigLong = (OrigLong / 180) * Pi
DestLong = (DestLong / 180) * Pi
AsinBase = Sin(Sqr(Sin((OrigLat - DestLat) / 2) ^ 2 + _
Cos(OrigLat) * Cos(DestLat) * Sin((OrigLong - DestLong) / 2) ^ 2))
AsinBase = (AsinBase / Sqr(-AsinBase * AsinBase + 1))
AsinBase = 2 * AsinBase * 6371 '6371 is the radius of the Earth in km
AsinBase = AsinBase * 0.621371 'this is for conversion to miles
Haversine = Round(AsinBase, 2) 'rounds to 2 decimal points
End Function
And then in a query, you can have a column with a calculated field that looks like this:
Distance: Haversine(<LatOfNew>,<LongOfNew>, [Table Name]![Latitude], [Table Name]![Longitude])
That should give you a general idea of what to do.
HTH