Akhtar,
On Wed, 12 Mar 2003 05:42:06 -0800, "Akhtar Hussain"
<akhtar.huss
...@fmg.co.uk> wrote:
>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.
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)