VB6 - Sort ID AutoNumber descending issue

Wilder1626
Wilder1626 used Ask the Experts™
on
Hello all

I have a MSHFexgrid1 that have data from my Microsoft Access dbase.

I want to sort column 1 that have the ID AutoNumber from  MS Access.

The problem is that when i do this, i see that result:
99
98... 'going down
89
88...  'going down
29
28...  'going down
100
1

So i don't have a real descending sorting.

How can i fix this?

Thanks again

Full code
'Sort grid
            With MSHFlexGrid1
                .Col = 1
                .Sort = flexSortStringDescending
            End With

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Create a column with zero width. Put the same data in the column except use Format(MyValue,  "00000"). Then sort on that column.
well, there is nothing wrong with the result you are getting, the result is based on String sorting

and in String sorting  100 is less than 28   ( one is less than 2 )

try to check if there is numeric sorting option or not

.Sort = flexSortNumricDescending  ( not sure if that exist or not , however you got the idea
As mentioned by honestman, you need to use flexSortNumericDescending.  For a list of other sort options, check out this link:
http://msdn.microsoft.com/en-us/library/aa261266(v=vs.60).aspx
Hello all

Thanks for all the help.

I will go with this:

            'Sort grid
            With Form3.MSHFlexGrid1
                .Col = 1
                .Sort = flexSortNumericDescending
            End With

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial