Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Order a recordset? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I'm hoping someone can help me modify this code. The code below loops through a Microsoft MapPoint recordset, and assigns ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Order a recordset? Is there a way that I can loop through the recordset to find the lowest value for "objRS2.Fields(24).Value", then assign the numbered pushpin symbol, then loop through the recordset again to find the next lowest value in that same field and then assign the next numbered pushpin symbol. I guess the structure that makes the most sense to me would be some sort of nested loop, but I can't seem to figure out how to structure it. Thanks so much. Dim objRS As MapPoint.Recordset Dim objDataSet As MapPoint.DataSet Set objRS = objDataSet.QueryAllRecords Set objDataSet = objApp.ActiveMap.DataSets.Item(2) intSymbol = 208 objRS.MoveFirst Do Until objRS.EOF objRS.Pushpin.Symbol = intSymbol intSymbol = intSymbol + 1 objRS.MoveNext Loop
__________________ Lead, follow, or get out of the way! |
| ||||
|
Hi Shecky, First try to distill it down to a more basic programming problem, don't complicate things with MapPoint. Are there ever any records with the same value? Try Google for "shell sort", this looks like one of the more basic algorithms: http://www.vba-programmer.com/VB_Cod...ng_Listbox.txt good luck, Eric
__________________ |
| |||
|
Thanks for the input. I'm a fairly novice programmer, so that's why I didn't appreciate the complexity of what I was posting. I'll look at your suggestion and post back.
__________________ Lead, follow, or get out of the way! |
| ||||
|
Shecky, By spooky coincidence I was after something very similar in the past hour or so. A RecordSet.SortOnName() would have been ideal for what I wanted but no such method exists. Therefore I had to sort the values after I have read them from the RecordSet. As a quick bit of coding, I wrote the following Bubble Sort: Code: Public Sub Sort(strKeys() As String, dat() As MapPoint.Location, n As Long)
' Crude Bubble Sort
' This should be replaced with a QuickSort at a future date
Dim i As Integer
Dim j As Integer
Dim swapString As String
Dim swapLoc As MapPoint.Location
For i = 1 To n - 1
For j = i + 1 To n
If (strKeys(i) > strKeys(j)) Then
swapString = strKeys(i)
strKeys(i) = strKeys(j)
strKeys(j) = swapString
Set swapLoc = dat(i)
Set dat(i) = dat(j)
Set dat(j) = swapLoc
End If
Next j
Next i
End Sub
Visual Basic isn't my native tongue as it were, so I was more than happy to get something like the above running, and then to replace it with a better type of sort later. Looking at the page that Eric has linked to... Eric, I'm pretty certain that that is a "QuickSort" rather than a "Shell Sort"! Just what I'm after I have a copy of the Pascal version of 'Sedgwick' here - and it looks like his recursive implementation. Shecky: If this is all new to you, then you probably won't know what all these sorts are. "BubbleSort" (ie. my code) is usually the first one mentioned in beginner programming texts. It is easy to understand and quick to write. However it is notoriously slow. Basically it works its way through finding the last object, then the next-to-last, etc. As each object is found it "bubbles" to the correct location by a long line of data swaps. "Shell Sort" is meant to be a bit faster, and QuickSort is generally a lot faster (although the worst case can be fairly slow). Speed is heavily dependent on the size of the data. Eg. if you're only sorting 10 items, BubbleSort is probably fast enough! Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools See the Geoweb Guru for online mapping |
![]() |
| Tags |
| order, recordset |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PushPin and Line Order | stevet | MapPoint 2006/2009 Discussion | 2 | 06-19-2006 12:37 PM |
| Pushpin Z Order | Anonymous | MapPoint 2006/2009 Discussion | 0 | 09-06-2004 05:00 PM |
| How is possible to force order in Recordset? | Anonymous | MapPoint 2006/2009 Discussion | 0 | 08-27-2004 03:06 AM |
| Order/Sort Recordset with pushpins ??? | Michelin | MapPoint 2006/2009 Discussion | 0 | 03-01-2004 01:54 AM |
| Deriving a recordset from a mappoint recordset | RichardHayes | MapPoint 2006/2009 Discussion | 0 | 09-06-2002 02:44 AM |
Tenerife Holiday
Find a great deal on a Tenerife holiday through UlookUbook! Check out the options online...