Hello all, I just had a little exchange with Andre on another thread about triggers and properties in a form. It seems that there is a bug both in NF 2.60 and NA 3.1 when the form’s CAPTION property is set in OnInit AND there is also an OnFormat trigger for a text box that tries to set the color of this text box. More precisely: 1) Create a new form. In the OnInit trigger, set the form’s CAPTION to some fixed text. 2) Place a text box on the form, with some arbitrary source expression. Give it a name (e.g. MyName). In its OnFormat trigger, set the foreground color for this text box with CurrForm.MyName.UPDATEFORECOLOR(255); 3) Run the form. There will be an error message saying that the control (ID of your text box) is unknown. 4) Move the assignment to CAPTION into the OnOpenForm trigger. The form will work properly. 5) Undo change 4), then remove the setting of the color from OnFormat. The form will still work properly. Only when both conditions are met (setting the CAPTION in OnInit and accessing a control in its OnFormat), the error will occur. [xx(] Any ideas?
You should not refer to the controls on the form in the OnInit trigger. Navision creates the controls after execution of the OnInit trigger. My guess what happens is: If a reference is made to CurrForm in the OnInit trigger, a new instance of CurrForm is created based on the status of the form at that moment: without controls. If you move the reference to CurrForm to the OnOpenForm trigger curForm is instantiated at a later moment: including the controls.