Editing data from a form trigger

Hello everybody! First I have to apologize for my english, but I’m just a german student :wink: So, please be patient with me… I have the following problem with Navision Financials v2.50 (german): I try to edit a value of a record from the OnNextRecord-Trigger of a form. It’s a table with only one record in it with only two fields: ID: Integer, Update: Text. I would like to change the value of the field ‘Update’ with from ‘Yes’ to ‘No’ with the following commands: OnNextRecord-Trigger VariableForTable.GET(1); // Record has ID = 1 VariableForTable.Update := ‘No’; VariableFotTable.MODIFY; When I try to do so I get an error everytime: “You can’t make changes to the database from this point of the code.” So, why do I get this error and how am I able to change a value of a record from a form? I would be very happy about any comment! Thanks in advance, Ole

Hi Olel If you look at the help for the triggers, they clearly specify that, through some of the Triggers you cannot make any changes(modify) to the Database, and the trigger you have written the code is one among them. You can check the help and see which trigger would meet your requirement. MK

I guess the questions is what are you trying to do? I am sure you could use another trigger . Cristi

Hi,

quote:


If you look at the help for the triggers, they clearly specify that, through some of the Triggers you cannot make any changes(modify) to the Database


It should be my fault, but if I look at the help I can see nearly nothing. Might be because of the version I use, but the help isn’t very helpful at all.

quote:


I guess the questions is what are you trying to do? I am sure you could use another trigger .


Ok, I try to explain what I want to do. I have a form in card-design (I hope it is called so, I mean not the table-design) with orders in it. In the form is a subform showing all the positions for the order in table-view. Behind this form are two tables: Order and Position. I have two other tables ‘Order archive’ and ‘Position archive’. When there changes in the form made by the user, the new order should be copied to the ‘Order archive’ and all the belonging positions should be copied to ‘Position archive’. (The archive tables are identical with the originals with one more field ‘Archive Number’ to differentiate between the archive records.) The problem when you use the OnModify an OnInsert trigger of the position-subform to copy the records to the archive is, that you made a whole copy for every record you change. But if a user opens one order and want to change the price in all of the positions it would be better if the archive-copy would be generated when the user leaves the record (i.e. OnNextRecord). Therefor I have another table with only one field ‘Update’ which could be ‘Yes’ or ‘No’ as text. Now I try to change this field to ‘Yes’ in the OnModify trigger of the position-table and to check the value in the OnNextRecord trigger, copy the data and set the field value back to ‘No’. And when I try that, I get the error message from above. Ok, I hope you are able to understand anything. And it would be really great if you can offer me any help! Thanks, Ole

Ole: I am not really sure getting you right but I think you would be better off using the OnModify trigger of the Order and Position table. Another task might be how to access the different versions of both tables. Regards Alarich