Results 1 to 4 of 4

Thread: [RESOLVED] Data in MS Access Database our of order with VB 2010 Interface

  1. #1
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 12
    Location
    Miami, FL
    Posts
    270

    Resolved [RESOLVED] Data in MS Access Database our of order with VB 2010 Interface

    VB 2010 Express + MS Access 2003

    I'm still a newbie with all this...but today I successfully configured an interface to work with a test database I created in MS Access 2003. The database consists of only 8 records with 10 fields.

    I used the basic built-ins with VB 2010 to build the interface in a simple form which shows only 6 of the 10 fields. It all seems to work well, that is the connection string built correctly, and I can run the program and view the individual records. My trouble is that when it goes to the 1st record it's actually the 3rd record in the database. And when I go to the last record it's actually the 2nd record in the database and the next to the last record is actually the first record in the database.

    I'm confused as to why the program seems to start at the 3 record and shifts the first two records to the end. All the records show up, it's just that they are somewhat out of order.

  2. #2
    Addicted Member
    Join Date
    Nov 11
    Posts
    129

    Re: Data in MS Access Database our of order with VB 2010 Interface

    Can you post some code?
    Click "Rate This Post" if I helped you in any way.

    The best process for finding help.
    Step 1: Google it
    Step 2: Google it again
    Step 3: Google it yet again
    Step 4: Ask on a forum
    Step 5: Go to Step 1

  3. #3
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 02
    Location
    Idaho
    Posts
    20,401

    Re: Data in MS Access Database our of order with VB 2010 Interface

    Don't count on the records in the database to be in any particular order, because they aren't. The database has the ability to order them in whatever way it finds most convenient. Access will show the data in a grid which is ordered by something, but whether or not that order reflects the way the data is stored is not something you should care about. After all, the order shown by Access can easily be changed by sorting on a different column.

    In your case, you should make sure that the data is coming in with whatever order you want to see them. This is typically done by adding an ORDER BY clause to the SQL statement.
    My usual boring signature: Nothing

  4. #4
    Hyperactive Member Vladamir's Avatar
    Join Date
    Feb 12
    Location
    Miami, FL
    Posts
    270

    Re: Data in MS Access Database our of order with VB 2010 Interface

    Thanks everyone for your prompt replies on this. I used the built-ins...I hope that explains it properly...by using the built-ins I only ended up with this as far as code goes:

    Code:
    Private Sub Table1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Table1BindingNavigatorSaveItem.Click
            Me.Validate()
            Me.Table1BindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.Db1DataSet)
    
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'Db1DataSet.Table1' table. You can move, or remove it, as needed.
            Me.Table1TableAdapter.Fill(Me.Db1DataSet.Table1)
    
        End Sub
    
        
    End Class
    I'm assuming that the real code which drives this is embedded in the toolbar that's on this form. How I would read that to determine what order the sql statement is making to order the records is what I would like to ask.

Posting Permissions

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