Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access VB Mapping to Mappoint Error 91

Status
Not open for further replies.

TaylorTot

Technical User
Dec 23, 2003
96
0
0
US
Hi,

I am trying to add a radius to my mappoint pushpins and have the
following code:


Option Explicit
Dim oMpApp As mappoint.Application
Dim oMap As mappoint.Map


Private Sub Command1_Click()
Dim oDS As mappoint.DataSet
Dim oRS As mappoint.Recordset


Set oDS = oMap.DataSets.Item("My Pushpins")
Set oRS = oDS.QueryAllRecords
Do Until oRS.EOF
Dim oShp As mappoint.Shape
Set oShp = oMap.Shapes.AddShape(geoShapeRadius, _
oRS.Location, 10, 10)
oShp.ZOrder geoSendBehindRoads
oShp.Line.Visible = False
oShp.SizeVisible = False
oShp.Fill.ForeColor = vbBlue
oShp.Fill.Visible = True
oRS.MoveNext
Loop
End Sub


Private Sub Form_Load()
' Try to attach to running instance of MapPoint
On Error Resume Next
Set oMpApp = GetObject(, "MapPoint.Application")
On Error GoTo 0


If oMpApp Is Nothing Then
' Attaching failed - try creating an object
On Error Resume Next
Set oMpApp = CreateObject("MapPoint.Application")
On Error GoTo 0


If oMpApp Is Nothing Then
MsgBox "Could not create MapPoint object"
End
End If
' make the app visible
oMpApp.Visible = True
End If


' Ensure MapPoint survives when app terminates
oMpApp.UserControl = True


' Retrieve the active map
Set oMap = oMpApp.ActiveMap
End Sub


This has worked in the past, but now I am getting a runtime error 91
(object variable or with block not set. . . ) at the following line:


Set oDS = oMap.DataSets.Item("My Pushpins")


Can anyone tell me why I might be getting this error and how to fix
it? Thanks!


 
The error means that oMap (your object) has not be set.

Set oMap=something in your command button.

maybe move Set oMap = oMpApp.ActiveMap to your command button event.

I tried to have patience but it took to long! :) -DW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top