MapPoint Forums

MapForums

Community of MapPoint and Virtual Earth Users and Developers




Order a recordset?

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 ...


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

Today's Posts Twitter Feed 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 10-12-2004
Junior Member
White Belt
 
Join Date: Oct 2004
Posts: 3
Order a recordset?

I'm hoping someone can help me modify this code. The code below loops through a Microsoft MapPoint recordset, and assigns a sequentially numbered Pushpin symbol to each record in the recordset. This code works perfectly fine, except that the recordset is not in the proper order that I need, and there doesn't seem to be a method available to sort the recordset object. I need my recordset to be ordered according to this field: objRS.Fields(24).Value

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!
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 10-12-2004
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 3,041
Blog Entries: 2
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
__________________
~ Now taking orders for MapPoint 2009 ~
~~
~ Upgrade to MapForums Plus membership ~
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 10-13-2004
Junior Member
White Belt
 
Join Date: Oct 2004
Posts: 3
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 10-15-2004
Winwaed's Avatar
Mapping-Tools.com
Black Belt
 
Join Date: Feb 2004
Posts: 1,142
Blog Entries: 22
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
The strKeys and dat arrays have indices 1..n (yes I know this can be generalised). The Location objects in 'dat' are sorted in alphabetical order according to the names in 'strKeys'

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
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
order, recordset


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
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


All times are GMT -5. The time now is 01:33 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 RC2
MP2K Magazine
Visitor Map

Tenerife Holiday
Find a great deal on a Tenerife holiday through UlookUbook! Check out the options online...



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 55 56 57 58 59