Wondering if I can force a DB record update when fields are updated on a form - but the changes are not being saved to the database? I'm sure this has been addressed on this forum but I can't find it this afternoon.
Below is the offending code:
Private Sub btnEpiCustom1_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom1.Click '// ** Place Event Handling Code Here ** Dim recSelected As Boolean Dim whereClause As String = String.Empty Dim dsCustomer As DataSet = Epicor.Mfg.UI.FormFunctions.SearchFunctions.listLookup(oTrans,"CustomerAdapter", recSelected, True, whereClause) Dim edv As EpiDataView = CType(oTrans.EpiDataViews("UD15"), EpiDataView) '// If a part is selected... if recSelected then messagebox.show(dsCustomer.Tables(0).Rows(0)("CustNum")) edv.DataView(edv.Row)("Number17") = dsCustomer.Tables(0).Rows(0)("CustNum") edv.DataView(edv.Row)("ShortChar18") = dsCustomer.Tables(0).Rows(0)("CustID") else messagebox.show("No Customer Selected") end if End Sub ***** It updates the fields on the open form but will not save them to the DB.
BTW... You might recognize that this is based on the answerbook "How to add a search and populate a text box (dsSearch & Filter)" The original code in the answerbook does update the database (CustXPart table) Not sure why my variation isn't.
Automatically saving would be a big assumption on the program's part, it doesn't know you are done making changes, you could have several
other buttons/events doing changes and you only want to save when
everything is done.
The code you have updates fields on the screen. To make it permanent you need to save it by clicking the save button or add otrans.Upate() to your code.
This is the same process that likely happened with the standard code, a change was made to the screen and then at some point a save was made.
If you exited without saving it might ask you if you want to save if you haven't already You may need to add a rowmod = "U" and/or a notify event to signal that something changed in the dataview.
Thanks, and I think I understand what you are saying.
What I don't understand why the system doesn't "know" that there were any changes made.
Confusing to me because the original the Epicor example does see the changes and updates the db - the only differences are the table name and lookup adapter.
Seems weird...
*** Here is a reference to the code in Epicor examples- this one updates the CustXPrt fields in the db (3692ESC)
Private Sub
btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs)
Handles btnEpiCustom2.Click