We ran into a rather disturbing problem with Jet 4.0 engine and Visual Basic 2008.

A simple database with two tables. Company and people. If you add a company and move to the child table, people, you can not save the child entries due to a concurrency error. The error exist even if you save the parent entry manually before entering the child table. We repeated our logic with an identical SQL Express 2008 database and did not have any problem.

Though trial and error we found that you had to save the dataset and then reload it before entering the child table. The following is what we came up with:

Private Sub PeopleDataGridView_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PeopleDataGridView.Enter

        Me.Validate()
        Me.DateTextBox.Text = CStr(Now)

        vAnswer = Me.IDTextBox.Text   ' The control property Visable must be True for this to work. If you don't want user to see, hide it behind another control.

        Me.Validate()
        Me.MasterTableBindingSource.EndEdit()
        Me.PeopleBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.BrooksMasterDB_DataDataSet)

        Me.MasterTableTableAdapter.FillBy_RecordNumber(Me.BrooksMasterDB_DataDataSet.MasterTable, CInt(vAnswer))
        Me.PeopleTableAdapter.Fill(Me.BrooksMasterDB_DataDataSet.People)

' The record number is negative if not saved and reloaded

            If CInt(vAnswer) < 0 Then
            Me.MasterTableTableAdapter.Fill(Me.BrooksMasterDB_DataDataSet.MasterTable)
            Me.PeopleTableAdapter.Fill(Me.BrooksMasterDB_DataDataSet.People)
            Me.MasterTableBindingSource.MoveLast()
        End If

    End Sub

The records should be in the ordered that they where entered.