Solved

VB6 - Sort ID AutoNumber descending issue

Posted on 2012-12-29
4
666 Views
Last Modified: 2012-12-29
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

0
Comment
Question by:Wilder1626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 167 total points
ID: 38730124
Create a column with zero width. Put the same data in the column except use Format(MyValue,  "00000"). Then sort on that column.
0
 
LVL 10

Accepted Solution

by:
honestman31 earned 167 total points
ID: 38730128
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
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 166 total points
ID: 38730134
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
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 38730139
Hello all

Thanks for all the help.

I will go with this:

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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question