Results 1 to 2 of 2

Thread: Sorting Databse Records

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    10
    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

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width