Solved

VB6 - Sort ID AutoNumber descending issue

Posted on 2012-12-29
4
654 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
4 Comments
 
LVL 45

Assisted Solution

by:Martin Liss
Martin Liss earned 167 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

771 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now