hi as i often need to run forms if something occurs (like showing the document after posting it, running a dialog after quantity changes in a sales line, a.s.o.), i often get the annoying message that form.RUNMODAL cant be used during write transactions. so i could either insert a COMMIT (which is not the best solution) or use RUN. the problem with run is that you have no control over the form after it has been run. another problem i encountered was that i ran a form in the SalesLine - Quantity OnValidate with form.RUN to let the user define some parameters when the quantity changes and then click ok to save it. my parameters were sucessfully saved, but the change in quantity on the sales line was NOT saved. even if no error occured: // Start Of Trigger … IF Quantity<xRec.Quantity then begin form.run; end; // End OF Trigger this does not work. my question: how would you all solve such problems like showing or running things during transactions?
You always need to use COMMIT to save changes in a database. And also I use .RUNMODAL in the OnValidate trigger of a field and it works fine. But it’s impossible to change info in database from this trigger.
well. i enter the changed quantity in a differet table and it does work. but if i enter 50 in the field quantity my form apperas, you click ok and in my table the entry is created, but in the sales line there is still 100 in the qty-field
I had similar problem when run a form from OnAfterInput. I didn’t solve this problem but there were several reasons of usinf this trigger. If you do this in form, you should try to use the OnAfterValidate trigger. It have to work fine.
The reason is (if I understand the problem) that you have two values of teh same field: in the table and shown on the form. Each time you open the form, it reads the values from table and shows it on the screen. If you manualy edit this values, they are correctly stored to the table. But: if you change the the value of the table from other object, the form still shows the previous value, and after any modification of any field, the whole record is saved to the table and rewites the stord value. Try to experiment with: CurrForm.Saverecord - call your form - CurrForm.update(false). The last command reloads the values from table without updating them from the actual shown values.
well the situation is this: on the onvalidate of the sales line TABLE i show a form where the user should set some options and then writes something into a DIFFERENT table without changing the sales line where it cam from. my piece of code is the last one in the on validate trigger. it looks like that: commit; if confirm(bla) then begin form.initilaize(somvalues); form.runmodal; end; i can do whatever i want, the quantity you entered will never be set on the sales line, unless i comment out the whole block of code.