How to find currently active control on form

Hi! How to find which control is currently active in form?

The table shown in the form knows at least what Field Number you are pointing to: CurrentFieldNo All you can do in a program is to fill in a variable in the onactivate trigger of a control and then check the content of that variable somewhere else.

I cannot find any methods to get CurrentFieldNo from table shown in form. How can i do this. It’s very usefull.

That is a kind of “CONSTANT” like USERID and COMPANYNAME, but this is only accessible inside the table , which means in any function or trigger in the table. You cannot access this variable inside a form. But I did not yet try to create a function inside the table which returns the value of CURRENTFIELDNO and use that one in the form.

I try to use CURRENTFIELDNO from rec in from. It works but only if the field is been edited. And return always last edited field No.

Then the only way is to use the OnActivate triggers of the controls, sorry.

The following information is taken off of the “Solution Development” PDF-Manual (Solution_Development.pdf). Since there is no reference to the CurrFieldNo system variable in the C/SIDE online help, I’m posting it here.

quote:

Field Event Triggers Every field in a table has its own event triggers. Within these triggers you also have access to Rec and xRec. There is also a new system variable provided for you called currFieldNo. It is described in detail in the following. OnValidate The OnValidate trigger fires when the user changes a field and leaves that field. This trigger fires before any other trigger can occur, like the OnModify, OnInsert, or OnRename (this includes form triggers that we will discuss later). You can use this trigger to make sure what the user entered into this field is valid or to populate other fields with values based on what the user entered here. This is probably the most commonly used trigger in Navision. During this event:
- Rec holds the values of all the fields that the user has changed or not changed.
- xRec is identical to Rec except that it holds the previous value of the field currently being edited.
- CurrFieldNo is set to the Field number of the field that the user changed. If the field’s validate trigger is called from some other field’s validate (originally initiated by the user), currFieldNo will be equal to the field number of the field the user originally changed. If the validate was called from code and not as a result of the user changing a field, CurrFieldNo is zero.
OnLookup The OnLookup trigger fires when the user clicks on the lookup button for that field. Any code whatsoever in this trigger (even comments) will cause C/SIDE to run only that trigger and ignore the default lookup that could have been set up by a table relation. For most fields this trigger is not used for that very reason. Most lookups in Navision are done via a table relation. This trigger, however, does allow the developer to write code for a custom lookup feature.

If Rec has the current (latest) data value, then use xRec so as to get the previous value [:D]