Calculate Distance and Travel Time

Download Sample Access File: Calculate Distance and Travel Time

This is an example Access file for calculating a distance and travel time between two places/addresses. In this sample, I calculate for result by using a google map method. The result from calculation will include the distance (mile/kilometer), travel time, and direction. The sample file also provides a button to view map on the Internet Explorer. All functions in this sample file are provided below.

Highlight functions in this file include:

#1 Your Address or Start Address

 This sample file needs two addresses to be calculated as I said at the beginning. So I will start from my address to the customer address. For this example, I created a table “MyAddress” to store my address. This table will have only one record of my address as shown below. You can change it to your address.

#2 Calculate Distance form

The Calculate Distance form displays both addresses from my company address and from customer address. It also provides a dropdown box to select a customer to find the distance. There are four buttons on this form: Calculate, Add New, Report, and View Map. The customer address appears on the left side and my address appears on the right side of this form. At the bottom, it provides a big text area to display a direction from my address to customer address.

#3 Select Destination and Calculate the Distance

You can select the customer from a dropdown list to find the distance and direction. For example, I select customer name “Paul Vang” and click Calculate button. The result will be:

  1. The distance is 6 miles.
  2. Travel time is 12 minutes.
  3. Direction Form box is showing full address of my address which is the starting place.
  4. To box is showing full address of customer address which is the destination place.
  5. The direction will show on big rectangle box.

#4 View Report

After clicking on the Report button, it will open a Direction report which shows two addresses, distance, travel time, and direction between these two addresses.

#5 View Map

After clicking on the View Map button, it will open a google map under the web browser.  The two addresses will show on the map with a detail direction from my address to customer address as shown in the picture below.

#6 Change a Measurement Unit

The information from calculation below is displayed in the length of Mile. However, you can change to the length of Kilometer depending on your region. In order to change to Kilometer, you need to:

  • Open a module “getDistance”
  • Change Const strUnits = “imperial” to Const strUnits = “metric”
  • Save and close module

#7 Calculate in Metric (Kilometer) Measurement

 After you change the measurement unit to Metric (Kilometer) and click on Calculate button, the distance calculation will display in Kilometer as 9.6 Kilometers. The length of distance will display in “m” (meter) and “km” (kilometer) as well on the direction box as shown below.

Download file contains:

3 Tables, 1 Form, 1 Report and 1 Module

Related posts