Question Locked

SORTING ACCESS TABLE FROM VISUAL BASIC APPLICATION

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I developed a Library Management Project using Visual Basic 6.0 and Access database. I use ADODC.
I wish to sort all of the books in the database in the ascending order of BookId. For this, I placed
a button which have the caption property "SORT". I
mean when click on this button, the entire books are sorted by ascending order of bookid within the database. How can I do it?... Can you give me an example code?

4 replies

by john.a.wills

I am not quite sure what you want: your table is ordered according to its properties. To change the order of the data as they appear on the form
My.OrderBy = "BookId".

by bsswale

The key field in the Access table is BookID, presumably. The records are already sorted!
If you want to sort using VB and not VBA then you need to read all the records from the Access table into an array in VB. Then use a standard sort method such as bubble-sort or maybe quicksort if there are a very large number of records. Then write the array back to the table. If I have time I'll write you the code - but I'm a bit busy marking student scripts at the moment.
Shane

This discussion is closed to new replies.