mappoint in access

nmilne
01-18-2006, 12:49 PM
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

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

Wilfried
01-19-2006, 02:08 PM
Hi,

which waypoint ?
There is also an endif missing, see copy of your code below with indent. Please use code tags next time so that code is more readeable.

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

nmilne
01-20-2006, 06:23 AM
im using mappoint 2004 ms access xp
if i put another end if in public function ApplyPoint()
the code won't work

Wilfried
01-22-2006, 05:48 AM
Hi,

Ok, sorry I tought that if then block in VB must be closed with end if, but I know not mutch of VB.

But reading again I now think I understeand what your question was. You have this location where you put the pushpin and wants to add a waypoint to a route right ? Here it go (in C#):

Waypoint wp;
Map map = mp.ActiveMap;
Route route = map.ActiveRoute;
wp = route.Waypoints.Add(loc, "");

'loc' is your Location object in AddPushpin: oLoc(1).Location; and in the second argument you add the name, I think in your code: me.PickupCustomer;

nmilne
01-25-2006, 10:00 AM
thank for the help
i have now found the info i needed
in ms access press the obect browser button
then in all libraries change it to mappoint
and all the comands are there
i have now got my mappoint working in database
on a form like lookup pickup customer
press the add to map button this then finds customer and then add it as pushpin pluse route start
then the same for my delivery address
this then calc the route then passes back to the database the info i need
like map of route + directions + time to do job + route cost + miles total
im very pleased with it
all i needed to do was find out the name diff from vb to vba
then some playing round with code
all the best
nick

 
Web mp2kmag.com
mapforums.com