PDA

View Full Version : Finding Pushpin Name by clicking on the Pushpin?(MP 2002)



NickSP
01-06-2003, 12:50 PM
Hi,
I am a relatively beginner programmer and would certainly appreciate your help with my problem.
I am adding with the help of a Recordset from an Access database to Mapoint and adding pushpins with names as IDs that I get from the Recordset from Access. So far so good.
What I want to know is can I select the ID or the pushpin name of each individually clicked pushpin? I am doing this in VB6 Thanks.
Nick.

John Meyer
01-06-2003, 06:30 PM
Nick,

You could put this in a command button.


Dim objmap As MapPointctl.Map
Dim objPushpin As MapPointCtl.Pushpin

Set objmap = MapPointControl1.ActiveMap
'Make sure the item selected on the map is a pushpin
If TypeOf objmap.Selection Is Pushpin Then
Set objPushpin = MapPointControl1.Selection
'Do Something
msgbox objpushpin.name
End If

NickSP
01-06-2003, 09:33 PM
John, the piece of code worked great. Thanks again.

stiemark
01-10-2003, 11:33 AM
If this is going to be used by other people, you also want to trap the case where there is no selection. If you don't do that, the program will error when you try to ask the typeof nothing.
Try this:


Dim objmap As MapPointctl.Map
Dim objPushpin As MapPointCtl.Pushpin

Set objmap = MapPointControl1.ActiveMap

'Make sure the item selected on the map is a pushpin
If Not objmap.Selection is nothing Then
If TypeOf objmap.Selection Is Pushpin Then
Set objPushpin = MapPointControl1.Selection
'Do Something
msgbox objpushpin.name
End If
End If

NickSP
01-10-2003, 12:11 PM
Thanks a lot Sitemark, I had already figured that out but not before encountering the error you talked about. (learning the hard way). But thank you very much for the code as any help is always appreciated.