MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




query shape produces wrong results

This is a discussion on query shape produces wrong results within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I am working on the following code to select pushpins graphically. I prefer not to send the data to Excel. ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-23-2002
Junior Member
Yellow Belt
 
Join Date: Jul 2002
Posts: 17
Send a message via AIM to David Kachuck
query shape produces wrong results

I am working on the following code to select pushpins graphically. I prefer not to send the data to Excel. If someone sees what's wrong with my code, I would appreciate the correction. The number of pushpins selected is always all of the pushpins on the map.

This is the code:

Private Sub mnuSelectRectangle_Click()
Dim intShapes As Integer
Dim longHeight As Long
Dim longWidth As Long
Dim longTop As Long
Dim longLeft As Long


Set objMap = MappointControl1.ActiveMap

longHeight = objMap.SelectedArea.Height
longWidth = objMap.SelectedArea.Width
longTop = objMap.SelectedArea.Top
longLeft = objMap.SelectedArea.Left

objMap.SelectedArea.SelectArea longTop, longLeft, longWidth, longHeight
Set objLoc = objMap.SelectedArea.Location

If longHeight = 0 Or longWidth = 0 Or longTop = 0 Or longLeft = 0 Then
MsgBox "Nothing selected. "
Exit Sub
End If

Set objShape = objMap.Shapes.AddShape(geoShapeRectangle, objLoc, CDbl(longWidth), CDbl(longHeight))
objShape.Select

MsgBox "The type of shape selected is " + CStr(objMap.Shapes.Item(1).Type)

Set objDataSet = objMap.DataSets.Item(2)

If objShape Is Nothing Then
MsgBox "objShape got lost"
End If

Set objRecordset = objDataSet.QueryShape(objShape)

' Loop over records and place the captured pushpins in a list box

objRecordset.MoveFirst
intShapes = 0
Do While Not objRecordset.EOF
frmSelectAccounts.lstAccounts.AddItem objRecordset.Pushpin.Name
objRecordset.MoveNext
intShapes = intShapes + 1
Loop

MsgBox "Number of records in shape: " + CStr(intShapes)
frmSelectAccounts.Show

End Sub
__________________
David Kachuck
dk0146@netscape.net

Oracle Certified Professional Database Administrator (OCP)
MS Access Certified Expert (MAUS)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 12-23-2002
John Meyer's Avatar
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
David,

I think this sample I posted might help?
Orignal post: http://www.mp2kmag.com/mappoint/disc...pic.asp?t=3327

Quote:
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.
Code:
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 12-24-2002
Junior Member
Yellow Belt
 
Join Date: Jul 2002
Posts: 17
Send a message via AIM to David Kachuck
select pushpins graphically

Thanks. That works. I don't really understand (yet) why my query shapes solution doesn't work, but hey, why blow against the wind?
__________________
David Kachuck
dk0146@netscape.net

Oracle Certified Professional Database Administrator (OCP)
MS Access Certified Expert (MAUS)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
produces, query, results, shape, wrong


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Does an object reside in my Shape or Shape boundaries? hotrdd MapPoint 2006/2009 Discussion 1 08-04-2005 10:51 PM
Linking access query results to MPC Anonymous MapPoint 2006/2009 Discussion 0 06-22-2004 12:25 PM
Query by shape / polygon blackmap MapPoint 2006/2009 Discussion 7 02-12-2003 04:35 AM
reverse geo coding, results wrong Anonymous MapPoint 2006/2009 Discussion 2 09-22-2002 10:11 AM
I have a J++ web application that produces reports.... Anonymous MapPoint 2006/2009 Discussion 1 11-17-2000 07:39 AM


All times are GMT -5. The time now is 11:22 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54