Saving a new record clears form

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I have been able to Add a new row to a dataset, and then save the new
row back to the data source. The problem is, after the data source is
updated, all the text fields in the form clear. Any ideas?

Here's my code:

Private Sub mnuAddNewPerson_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles mnuAddNewPerson.Click
...
Dim personRow As DataRow
...
ds.Tables(0).Clear()
personRow = ds.Tables(0).NewRow
ds.Tables(0).Rows.Add(personRow)
...
End Sub

***

Private Sub mnuSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuSave.Click
...
cmPeople.EndCurrentEdit()
daPersonMain.Update(ds, "PersonBasic")
...

End Sub
 
you obviously have the form bound to the data source...i don't do binding,
but there should be an overwriteable interface on the form class so that
when the "recordNew()" (or whatever the interface) event is raised, you can
intercept it and substitute your code in lieu of what is undesireably
happening behind the scenes when you are adding a new person.

hth,

steve
 
Hi Brian,

Perhaps the Form loses track and you need to navigate it 'back' to the
record it was just on??

Regards,
Fergus
 
Back
Top