| Retrieving Time and Distance
Hello,
This VBA code reads the directions created by mappoint and updates a table in ms access s= directions counter and stops = waypoint item
I hope this will answer your question.
Private Sub WAYPOINT_Click()
On Error GoTo err_wp_CLICK
Dim objMap As MapPoint.Map
Set objMap = Forms!MAPPLAN.csgmAP.ActiveMap
Dim objLoc As MapPoint.location
Dim objpushPin As MapPoint.Pushpin
Dim na As String
Dim ti As Date
Dim s As Integer
Dim STOPS As Integer
Dim last As Integer
Dim mi As String
STOPS = 1
last = objMap.ActiveRoute.directions.count
s = 1
DoCmd.SetWarnings False
DoCmd.OpenQuery "gpsclearroute"
loopstops:
na = objMap.ActiveRoute.Waypoints.Item(s).name
ti = objMap.ActiveRoute.directions.Item(STOPS).StartTim e
If objMap.ActiveRoute.directions.Item(STOPS).Distance = 0 Then mi = 0 Else mi = Format(CDbl(objMap.ActiveRoute.directions.Item(STO PS).Distance), "#.#")
'MsgBox (s & "--" & na & " -- Dir: " & STOPS & " -- Time: " & ti & " -- TURNS: " & di)
If mi = "." Then Me!mi = 0 Else Me!mi = mi
Me!wp = s
Me!ti = ti
Me!na = na
Me!st = STOPS
Me!di = di
di = objMap.ActiveRoute.directions.Item(STOPS).instruct ion & " for " & Me!mi & " miles"
Me!wa = objMap.ActiveRoute.Waypoints.Item(s).StopTime * 1440
Me!arr = (objMap.ActiveRoute.Waypoints.Item(s).PreferredArr ival)
DoCmd.OpenQuery "gpsbuildroute"
If STOPS >= last Then GoTo display
STOPS = STOPS + 1
If na <> objMap.ActiveRoute.directions.Item(STOPS).WAYPOINT .name Then s = s + 1
If STOPS <= last Then GoTo loopstops
display:
DoCmd.OpenQuery "gpsrouteend"
DoCmd.OpenQuery "makegpstemp"
DoCmd.OpenQuery "gpsplotupdate"
DoCmd.SetWarnings True
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "poproute"
'stLinkCriteria = "[route]=" & "'" & Me![mname] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
err_wp_CLICK:
End Sub
CSG |