Option Compare Database
Option Explicit
Private oMap As MapPoint.MappointControl
Private oCustomers As MapPoint.DataSet
Private objSA As MapPoint.StreetAddress
Private oPush As Pushpin
Private oLoc As Object
Private Sub cmdPlot_Click()
If txtAddress <> "" Then
ApplyPoint
End If
End Sub
Private Sub Form_Close()
oMap.ActiveMap.Saved = True
Set objSA = Nothing
Set oLoc = Nothing
Set oPush = Nothing
Set oMap = Nothing
End Sub
Private Sub Form_Load()
Set oMap = MapCtl.Object
oMap.NewMap geoMapEurope
txtAddress = "Me.txtpickupAddress"
End Sub
Public Function ApplyPoint()
If oMap Is Nothing Then Set oMap = Me!MapCtl.Object
Set objSA = oMap.ActiveMap.ParseStreetAddress(txtAddress)
Set oLoc = oMap.ActiveMap.FindAddressResults(objSA.Street, objSA.City _
, , objSA.Region, objSA.PostalCode)
If Not oLoc Is Nothing And oLoc.ResultsQuality <> geoNoResults Then
Set oPush = oMap.ActiveMap.AddPushpin(oLoc(1).Location,
me.PickupCustomer)
oPush.BalloonState = geoDisplayName
oPush.Location.GoTo
Set oPush = Nothing
Set oLoc = Nothing
End If
End Function
>Can some one help me with this access vba code please
>I want it to add the waypoint (1) after the addpushpin(1)
>I don’t know how to do this
Check out the ActiveRoute object of the map. Clear it to start a new
route, then add location or pushpin objects (at least two of course)
to its WayPoints collection.
(
oMap.ActiveRoute.Waypoints.Add oPush
should work in your context - optionally provide a name for the stop
)
Finally, call ActiveRoute.Calculate to calculate the route. Results
such as driving time or distance are then available as properties of
the ActiveRoute.
Regards,
Gilles [MVP].
(Please reply to the group, not via email)
Nick,
Gilles gave you the answer to adding a WayPoint to the WayPoints collection
of the ActiveRoute and it does not require Access. You simply need to tell
the
ActiveRoute to Calculate and/or Optimize once you've finished adding points.
For database design and programming topics, try the following:
Access-L
http://peach.ease.lsoft.com/archives/access-l.html#SUB
Access-D
www.databaseadvisors.com
Both groups have searchable archives.
www.rogersaccesslibrary.com for sample Access databases.
www.mp2kmag.com for articles using Access and MapPoint.
----
Michael R. Mattys
Mattys MapLib for Microsoft MapPoint
http://www.mattysconsulting.com