4 Replies - 1212 Views - Last Post: 18 December 2012 - 09:23 PM Rate Topic: -----

#1 levin  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 08-February 11

how to call data from recordset sorting largest to smallest number

Posted 17 December 2012 - 02:07 AM

    Dim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim col, rows As Integer
    rows = 1
     conn.Open "asois"
         rs.Open "select * from graph", conn, 3, 3
            
             Set grid2.Recordset = rs

                 With grid2
                         .Sort = 2
                 End With

             For I = 0 To rs.RecordCount - 1
    
                With chart1
                    .Column = 1
                    .Row = rows
                    .RowLabel = rs!StockName & " - " & rs!Brand
                    .Data = rs!Quantity
                    
                End With

                rows = rows + 1
              rs.MoveNext
            Next I
    Set rs = Nothing
    Set conn = Nothing




as shown in the picture i am trying to sort the Quantity in the MSChart from largest - to - smallest number (in the picture it shows largest number is 850 and the smallest is 50) i am trying to sort it making 850 the first(Color Red) to be call in the database up to the smallest number. i have tried using MoveFirst but the output is still the same with the picture shown.

i have also tried to sort the Datafield, made the DataType = Numbers and i Sort Largest To Smallest but still the same output..

Attached image(s)

  • Attached Image

This post has been edited by levin: 17 December 2012 - 02:13 AM


Is This A Good Question/Topic? 0
  • +

Replies To: how to call data from recordset sorting largest to smallest number

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: how to call data from recordset sorting largest to smallest number

Posted 17 December 2012 - 07:50 AM

Could you not just do that in your query??

Something like...

Select * from graph order by quantity desc

Was This Post Helpful? 1
  • +
  • -

#3 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9057
  • View blog
  • Posts: 34,001
  • Joined: 12-June 08

Re: how to call data from recordset sorting largest to smallest number

Posted 17 December 2012 - 08:05 AM

Why not sort it in the SQL statement? You know - throw an "ORDER BY <column name>"?
Was This Post Helpful? 1
  • +
  • -

#4 levin  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 08-February 11

Re: how to call data from recordset sorting largest to smallest number

Posted 17 December 2012 - 02:41 PM

:bananaman: ahahaha tnx alot guys :D its working!
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: how to call data from recordset sorting largest to smallest number

Posted 18 December 2012 - 09:23 PM

See here for correct use of the Sort property. It can be quite useful if you don't want to rerun your query..

This post has been edited by BobRodes: 18 December 2012 - 09:26 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1