473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Saving a new record clears form

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
Nov 20 '05 #1
3 1101
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
"Brian" <br*********@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
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

Nov 20 '05 #2
Cor
Hi Brian,
Dim personRow As DataRow You create a new empty row
ds.Tables(0).Clear() The whole Table(0) is cleared (I asume that it is your only table)
personRow = ds.Tables(0).NewRow You fill the personRow with the structure of the dataset
ds.Tables(0).Rows.Add(personRow)

You add an empty row to your dataset Table(0), who exist of zero rows.

What do I see wrong?

Cor

Nov 20 '05 #3
Hi Brian,

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

Regards,
Fergus
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST ==...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
11
by: kaosyeti | last post by:
i have a form that records 9 fields into a table. on that form i have a 'done' button to close the form. right now, if the form is fully filled in, but you don't press 'enter' before you click...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
1
by: google | last post by:
I have a form with several subforms. Users enter the data, then on the parent there is a command button that runs code to generate a .pdf document from a report based on the data they are working...
3
by: Andy_Khosravi | last post by:
I'm having a problem with an entry form on one of my applications. It would appear that the save action is sometimes not working, and is generating no error when it fails. I'm hoping one of you may...
1
by: Cesar Zapata | last post by:
Hi, I have a a bound subform and what i'm trying to do is do check if some criteria applies before saving the record and trigger a macro. basically this is what I got. Date Received ...
3
by: chuch | last post by:
Hi, i have created a database to store contractors invoices. I have approximately 9 tables and 3 forms. One of my forms(frmContractors) has all the contractor details and this also contains a sub...
3
by: menkenk | last post by:
Hello, I created a form with multiple tabs. They are labeled as Info, Policy, Riders. The Info Tab is linked to the Client Information Table, the Policy tab is linked to the Client Policy...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.