Thread: Selected Area
View Single Post

  #3 (permalink)  
Old 08-21-2002
John Meyer's Avatar
John Meyer John Meyer is offline
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
Give this a try, I think it will do what your asking. I'm just counting the number of pushpins in the selected area (the rectangle made when holding the left mouse button and dragging) but you could get there name/location or whatever you need.. BTW, If you did not select an area it will just exit sub.

Private Sub Command1_Click()
On Error GoTo error:
Dim objmap As MapPointctl.Map
Set objmap = MappointControl1.ActiveMap

Dim sa As MapPointctl.SelectedArea
Set sa = objmap.SelectedArea

Dim objDataSet As MapPointctl.DataSet
Dim objRecords As MapPointctl.Recordset


Dim objLocs(1 To 5) As MapPoint.Location
Set objLocs(1) = objmap.XYToLocation(sa.Left, sa.Top)
Set objLocs(2) = objmap.XYToLocation(sa.Left + sa.Width, sa.Top)
Set objLocs(3) = objmap.XYToLocation(sa.Left + sa.Width, sa.Top + sa.Height)
Set objLocs(4) = objmap.XYToLocation(sa.Left, sa.Top + sa.Height)
Set objLocs(5) = objmap.XYToLocation(sa.Left, sa.Top)

'Remove the comment from the next line to see the polygon being queried
'objmap.Shapes.AddPolyline objLocs

lngCount = 0

For Each objDataSet In objmap.DataSets
Set objRecords = objDataSet.QueryPolygon(objLocs)
objRecords.MoveFirst
Do While Not objRecords.EOF
lngCount = lngCount + 1
objRecords.MoveNext
Loop
Next
MsgBox "Number of records in polygon: " & lngCount

Exit Sub
error:
MsgBox Err.Description
End Sub
__________________
John
http://www.support-pc.com

Order MapPoint 2006 Here
https://secure.mp2kmag.com/?refer=support-PC
Reply With Quote