View Full Version : VBA calling MP2k2

01-14-2003, 10:55 PM
I am trying to give the ability to my user to look up a record in an access form, click a button and the load the map with that records address. It works fine yet when they switch to a new record and hit the map button again this new adress does goes on the original map, yet another mappoint windows loads. So now I have the two map point windows open the original with two pins and another that is just blank USA. And so on and so forth... 3 different records mapped - 3pins on orig map now two extra windows of map point. I beleive it is my code calling the new window but i just want each new recoard to go onto one map.

Is there a peice of code that will just add a new pin to the current map.
How might I referance the original windows/object
I am not using datasets because I done know what records the user might choose.

Thanks in advance, Roger

Here is my code that will run every time the user switches to a new record clicks the map button on the form.


Dim MPApp As MapPoint.Application
Set MPApp = CreateObject("MapPoint.Application")
Set omap = GetObject(, "MapPoint.Application").ActiveMap
Dim oLoc As MapPoint.Location
Dim oPin As MapPoint.Pushpin
Dim StreetAdr As String

StreetAdr = Me.delivDayAddress + "," + Me.delivDayZip

Set oLoc = omap.FindAddressResults(Me.delivDayAddress, , , , Me.delivDayZip)(1)
Set oPin = omap.AddPushpin(oLoc)
oPin.Name = [Forms]![LogCustomer]![FirstName] & " " & [Forms]![LogCustomer]![LastName]
oPin.BalloonState = geoDisplayBalloon
oPin.Note = Me.delivDayPhone
oPin.Symbol = 25

MPApp.WindowState = geoWindowStateMaximize
MPApp.UserControl = True
MPApp.ActiveMap.Saved = True
MPApp.Visible = True

John Meyer
01-15-2003, 05:45 AM

On the first go around, MapPoint is not running yet so this part of your code is needed

Set MPApp = CreateObject("MapPoint.Application")

If MapPoint is running already this line of code starts another copy.

01-15-2003, 11:47 AM
Is there a line of code that can see if it is already loaded once?

Thanks again for the quick responce!