GlobalVars on Rec

Could someone explain why this happens? I created a table with - Some fields - A global variable (MyGlobalVar Text(30)) - Two functions · SetGlobalVar(Value Text(30)) MyGlobalVar := Value; · GetGlobalVar() Text(30) EXIT(MyGlobalVar); I created a tabular form for this table with some fields and - OnOpenForm · SetGlobalVar(‘MY GLOBAL VAR VALUE’); - OnAfterGetCurrentRecord · MESSAGE(GetGlobalVar); When I open the form I see the message showing the value ‘MY GLOBAL VAR VALUE’ and when I move through records I get the same message. But after I create a new record or modify a value then I see the message window with no message (’’). Why is the Global Variable loosing its value? Thanks in advance.

I think When you create a new rec, Program will INIT the new rec, so it will loose all the settings to the rec. Since your function is on the table, it is clearing the rec, as well as the variable with in the rec. Now if you have a variable on the form itself then program will not loose the value of the variable/ function on the form. Also if you call that SetGlobalVar function on the “Form - OnAfterGetRecord”, then will get the value again after you create a new record. Naveen Jain

Hi Navieen, that correspont to my experiences. if you call an explicit INIT on a variable all global variables will be reseted. br Josef Metz