Mappoint 2010 -
11-21-2011
, 09:36 AM
Am just playing with mappoint 2010 and using the following to add pushpins
Private Sub AddPushpins_Click()
If Nz(ZoomHeight) < 5 Or Nz(ZoomHeight) > 2000 Then
MsgBox MsgBox "The acceptable range for the 'Zoom Height' is from 5 to 2000",
vbInformation Exit Sub
End If
'Dim MPApp As New MapPoint.Application
Dim MPApp As MapPoint.Application
Dim objMap As MapPoint.Map
Dim objDataSet As MapPoint.DataSet
Dim objSymbol As MapPoint.Symbol
Dim arArray()
Dim StgMapConnect As String
Dim i As Integer
' On Error GoTo AddPushpins_Err
'Open the map
'Set MPApp = New MapPoint.Application
Set MPApp = CreateObject("Mappoint.Application")
Set objMap = MPApp.OpenMap(FindMapPath())
If objMap.DataSets.Count > 1 Then ' Mapping is linked
For i = 1 To objMap.DataSets.Count
If If objMap.DataSets(i).Name = "QMapRefsPC" Or objMap.DataSets(i).Name =
"QMapRefsNoPC" Then MsgBox "You must remove the old data " &
objMap.DataSets(i).Name & " before procceeding", vbCritical
GoTo AddPushpins_Exit
End If
Next
End If
StgMapConnect nect = CurrentDb.Name & "!qMapRefsPC" ' This program with Post
Codes
Set Set objDataSet = MPApp.ActiveMap.DataSets.LinkData(StgMapConnect, "Ref",
, geoCountryUnitedKingdom, , geoImportAccessQuery)
arArray rray = Array(objDataSet.Fields("Ref"), objDataSet.Fields("Town"),
objDataSet.Fields("Web"))
'Set which fields will be visible in the Pushpin balloon
objDataSet.SetFieldsVisibleInBalloon arArray
MPApp.Visible = True
MPApp.UserControl = True
Set objMap = MPApp.ActiveMap
MPApp.windowstate = geoWindowStateMaximize
MPApp.ActiveMap.Altitude tude = ZoomHeight ' Set altidude so that numbers can
be seen Set objSymbol = objMap.Symbols.Add(FindMapPath() & "\Blue Dot.bmp")
objDataSet.Symbol = objSymbol.ID
Let objDataSet.HyperlinkType = geoHyperlinkField
Let objDataSet.HyperlinkField = objDataSet.Fields("Web")
GoTo AddPushpins_Exit
StgMapConnect nect = CurrentDb.Name & "!qMapRefsNoPC" ' This program without
Post Codes
Set Set objDataSet = MPApp.ActiveMap.DataSets.LinkData(StgMapConnect, "Ref",
, geoCountryUnitedKingdom, , geoImportAccessQuery)
arArray rray = Array(objDataSet.Fields("Ref"), objDataSet.Fields("Street"),
objDataSet.Fields("Web"))
'Set which fields will be visible in the Pushpin balloon
objDataSet.SetFieldsVisibleInBalloon arArray
objDataSet.Symbol = objSymbol.ID
Let objDataSet.HyperlinkType = geoHyperlinkField
Let objDataSet.HyperlinkField = objDataSet.Fields("Web")
AddPushpins_Exit:
Set MPApp = Nothing
Set objMap = Nothing
Set objDataSet = Nothing
Exit Sub
AddPushpins_Err:
MsgBox Err.Description
End Sub
On the line
Set Set objDataSet = MPApp.ActiveMap.DataSets.LinkData(StgMapConnect, "Ref",
, geoCountryUnitedKingdom, , geoImportAccessQuery)
I get error 4030 "Cannot import data because a connection to the database
could not be established."
What an I doing wrong?
Thanks
Phil |