PDA

Click to See Complete Forum and Search --> : Sorting Databse Records


VB_Novice
Mar 30th, 2000, 01:44 AM
Hello,

I am using VB 5 as an interface to an Access 97 database. When I add a new record to a table through the VB interface it goes to the Access table no problem and is also sorted correctly in this table.

However, when I view the records in the table using the VB interface they are not sorted and the record which has just been added is shown as the last record, even if it's primary key has a lower value than the previous record.

Is there any code I can use to sort these records, so when viewing through them in the VB interface, (after new records are entered), they will be sorted as in the Access table.

Hope someone can help,
Thanks,
Andrew

bsmith
Mar 30th, 2000, 02:41 AM
You need to add an Order By to your Select statement. When you open the database in Access, the table is sorted by the primary key by default. So when you insert a record it looks like the record was inserted where you wanted it. What actually happens is the record is added to the end of the table. When you do your select in VB add the order by clause and see what happens.