Situation: 2 forms , Access 2003 database
Combobox on form 1 not showing changed or new records unless I exit debugger and then run it again.
form2 contains datagrid, dataset, tableadapter, binding source, load code, save code, add record code
[Binding source]
Datasource = ProFlow1DataSet
Datamember = orificedata
[Datagrid]
Bindingsource = Proflow1DatSetBindingSource
Load code
Code:
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Save code
Code:
Me.OrificedataTableAdapter.Update(ProFlow1DataSet.orificedata)
If I edit data in the datagrid and click save, the datagrid show the changed value.
BUT if I add a new item to the datagrid I notice the ID [primary key in the .mdb table] shows a negative number rather than a sequential positive number after I click the Add button.
If I close that form and reopen it, the ID number is then sequential as it should be. I have a feeling this may be tied in with the main problem of the combobox on form1 now showing updated values. Here's the code that adds a new record to the datagrid
Code:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Adds Orifice Information to Datagrid by writing to the orificedata table in the db and updating the datagridview
Dim dsNewRow As DataRow
Dim userMsg As String
'Prompt the user to name the new orifice
userMsg = Microsoft.VisualBasic.InputBox("Enter a Name for the ORIFICE", "C&D ProFlow Orifice Data", "Example: Intake-1 or Exhaust-1")
'Do the updating work to the database table
dsNewRow = ProFlow1DataSet.orificedata.NewRow
dsNewRow.Item("diameter") = Me.TextBox3.Text
dsNewRow.Item("area") = Me.TextBox7.Text
dsNewRow.Item("Cd") = Me.TextBox5.Text
dsNewRow.Item("Range") = Me.TextBox8.Text
dsNewRow.Item("Name") = userMsg
ProFlow1DataSet.orificedata.Rows.Add(dsNewRow)
'Update the datagridview with the new data
OrificedataTableAdapter.Update(ProFlow1DataSet)
End Sub
Form 1 has the combobox that is not updating.
[combobox]
datasource = Proflow1DatSetBindingSource
Display member = name
Bindingsource [underneath the form] = Bindingsource = Proflow1DatSetBindingSource
[Proflow1DatSetBindingSource]
Datasource = ProFlow1DataSet
Datamember = orificedata
Form1 load code
Code:
Me.OrificedataTableAdapter.Fill(Me.ProFlow1DataSet.orificedata)
Ok..that's the layout... I hope I included everything.