Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AddPushpin Error 4013

12 views
Skip to first unread message

Akhtar Hussain

unread,
Mar 12, 2003, 8:42:06 AM3/12/03
to
I am trying to add a number of pushpins but every time i
use the AddPushpin method I get an erroe saying
'The requested set does not exist'

Here is my code : -

'Create a new pushpin set.
mappoint.ActiveMap.DataSets.AddPushpinSet "Suppliers"

'Get the DataSet object from the pushpin set
Set objDs = mappoint.ActiveMap.DataSets("Suppliers")
objDs.Select
'loop through the SQL data...
Do While Not rs.EOF
'Create a location object from the latitude and
longitude on the database.
Set objLocTst = mappoint.ActiveMap.GetLocation(rs!
Latitude, rs!Longitude)

'Add a pushpin at that location with a name from
the "LocationName" field on the database
' Debug.Print objDs.Name
Set objPin = mappoint.ActiveMap.AddPushpin
(objLocTst, rs!Name)
'Make sure the balloon is closed.
objPin.BalloonState = geoDisplayNone
'Put additional data in the note field of the pin.
strNote = rs!AccountNumber & vbCrLf & _
IIf(IsNull(rs!TownCity), "", rs!County
& vbCrLf) & _
rs!City & ", " & rs!Country & " " &
rs!PostCode & vbCrLf
objPin.Note = strNote
'Cut the pin out of "My Pushpins"...
objPin.Cut
'... and paste into "Locations from DB"
objDs.Paste
'Get the next database record.
rs.MoveNext
Loop

Any help would be welcome.

Gilles Kohl [MVP]

unread,
Mar 12, 2003, 3:37:50 PM3/12/03
to
Akhtar,

I modified your code so that it does not need your data:

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


Private Sub Command1_Click()


'Create a new pushpin set.

oMap.DataSets("Suppliers").Delete
oMap.DataSets.AddPushpinSet "Suppliers"



'Get the DataSet object from the pushpin set

Dim objDs As MapPoint.DataSet
Set objDs = oMap.DataSets("Suppliers")


objDs.Select
'loop through the SQL data...

Dim I As Integer

For I = 1 To 20


'Create a location object from the latitude and longitude on
the database.

Dim objLocTst As MapPoint.Location
Set objLocTst = oMap.GetLocation(49 + I, 10 + I, 0)



'Add a pushpin at that location with a name from the
"LocationName" field on the database
' Debug.Print objDs.Name

Dim objPin As MapPoint.Pushpin
Set objPin = oMap.AddPushpin(objLocTst, "Name" & CStr(I))


'Make sure the balloon is closed.
objPin.BalloonState = geoDisplayNone
'Put additional data in the note field of the pin.

Dim strNote As String
strNote = "This is some" & vbCrLf & "text for the" & vbCrLf &
"note part"


objPin.Note = strNote

'Cut the pin out of "My Pushpins"...
objPin.Cut
'... and paste into "Locations from DB"
objDs.Paste

Next I
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


The problem is, with this version I cannot reproduce the problem. Are
you sure the error message you get doesn't have to do with your data
access ?

Regards,
Gilles [MVP].

(Please reply to the group, not via email)

Akhtar Hussain

unread,
Mar 13, 2003, 5:08:34 AM3/13/03
to
Giles,

I appreciate your answer and I tried the code. It works but the problem I
seem to be having is that it works
using the mappoint application object but it seems to fail if I use the
Active X control.

I don't think it is the data access that is wrong.

Thanks for your help.


"Akhtar Hussain" <akhtar....@fmg.co.uk> wrote in message
news:02cc01c2e89d$2bc18ed0$2f01...@phx.gbl...

Gilles Kohl [MVP]

unread,
Mar 13, 2003, 12:33:50 PM3/13/03
to
>I appreciate your answer and I tried the code. It works but the problem I
>seem to be having is that it works
>using the mappoint application object but it seems to fail if I use the
>Active X control.

Here's a (somewhat streamlined) version using the ActiveX control:

Option Explicit
Dim oMap As MapPointCtl.Map
Dim objDs As MapPointCtl.DataSet

Private Sub Command1_Click()
Dim I As Integer

For I = -89 To 89
Dim objLocTst As MapPointCtl.Location
Set objLocTst = oMap.GetLocation(I, 2 * I, 0)

Dim objPin As MapPointCtl.Pushpin


Set objPin = oMap.AddPushpin(objLocTst, "Name" & CStr(I))

objPin.BalloonState = geoDisplayNone
objPin.Note = "Some text" & vbCrLf & "for the note"

objPin.MoveTo objDs
Next I
End Sub

Private Sub Form_Load()
MappointControl1.NewMap 1
Set oMap = MappointControl1.ActiveMap
Set objDs = oMap.DataSets.AddPushpinSet("Suppliers")
End Sub

Akhtar Hussain

unread,
Mar 14, 2003, 12:53:25 PM3/14/03
to
Giles,

That worked !

In my map I was opening a map and not setting the map to the control.

You've been a great help and have saved me a lot of head scratching.

Thanks for all your help.

Akhtar


"Akhtar Hussain" <akhtar....@fmg.co.uk> wrote in message
news:02cc01c2e89d$2bc18ed0$2f01...@phx.gbl...

Gilles Kohl [MVP]

unread,
Mar 14, 2003, 4:54:16 PM3/14/03
to
Akhtar,

On Fri, 14 Mar 2003 17:53:25 -0000, "Akhtar Hussain"
<akhtar....@fmg.co.uk> wrote:

>Giles,
>
>That worked !
>
>In my map I was opening a map and not setting the map to the control.
>
>You've been a great help and have saved me a lot of head scratching.
>
>Thanks for all your help.

You're welcome - glad to hear you were able to find the problem !

0 new messages