Update table using multiple datawindows and PFC
Posted on 2004-08-16
The question title says it all; how do I update one database table using multiple datawindows (pointing to the same table) and PFC?
Here is the situation (simplified):
1 window with the following:
- 3 command buttons
- 1 tab control with 2 tab pages
- On tabpage 1, there is 1 datawindow.
- On tabpage 2, there is a tab control with 5 tabpages. Each tabpage has 1 datawindow
All the datawindows are pointing to 1 table. There is a 'New' button that resets & inserts a row into the datawindows, allowing the user to enter a new thing.
When the user clicks Apply, the program calls the pfc_Save function. It results in an error (duplicate primary key) when it attempts to update the 1st datawindow on the 2nd tabpage.
I understand why it is giving me the error but need help with the solution. Why it's giving me the error? The first datawindow inserts a row into the table successfully. However, the 2nd datawindow attempts to insert a row using the same primary key. The 2nd datawindow should perform an update, not an insert. Please help!
Questions? Please ask.