Error Message in OnInsert trigger

I need the form to display error message when user tries to insert record when a variable is not blank. Basically do not allow new records to be inserted when the variable has a value. I tried adding the code to the OnInsertRecord trigger of form and also alternatively to the OnInsert trigger of the table. The error message is displayed and insertion is stopped, which is good. But after that whatever user tries to do(close form, move to previous record) the error message keeps popping up, stopping any further action. The form is tabular subform. Any ideas why this happens? Thanks. Pari Somasundaram.

Does that value that is supposed to be blank depend on a value of another field on that record? If so you could try something like this… Example. Lets say on a sales line you do not want to quantity to be entered if “Type” was blank(Standard Notes) On the Quantity field of the form you could do something like this… OnBeforeInput if type = 0//blank currform.quantity.editable := false; this would make the field noneditable and therefor the user could not enter in a value. Just a suggestion if I understood you right. Taylor McCartney Development Specialist CSB Systems

Hi Pari, are you sure that you want functionality like this? Navision’s opinion is that the user can do what he wants until the data is used at a crucial point like posting. But that is a whole other topic: idiot proofing Try this in the OnInsert Trigger of the table:

IF YourField <> '' THEN
  IF CONFIRM('%1 must be blank.\Delete record?', FALSE, FIELDCAPTION(YourField)) THEN BEGIN
    Rec := xRec;

Does it solve your problem? Regards, Reijer. PS: You can also teach your users the usage of F4. PPS: You are really pushing the limits of Navision. Twenty interesting, time consuming, questions in 2 months? I love it!

Maybe this question should sounds kinda stupid… but… have u think about modifying the onInsert trigger on the table for doing something like this instead: OnInsert if (myBlankedField <> ‘’) then BEGIN myBlankedField := ‘’; //Optionally add a Message('myblanked field has been blanked… :slight_smile: '); END; Regards Alfonso Pertierra (Spain)