Subform on a card type form tab get always focus on open

Hi, I have a quite annoying problem.

On some card-type forms I added a tab which holds a subform inside it (look at the sample picture).

It works fine but for a little problem - when a new record is inserted in the main form and the form is closed, it always reopens on the tab holding the subform, with focus on the subform first line.

I cannot find a way to force the damned thing to open on the first tab. Any idea?

Hi Anna,

I’m sure you already tried to change the ActiveControlOnOpen property?

If that didn’t help, then it might be something about the control numbering of your subform. I had this problem a long time ago, but I really cannot remember exactly how to solve it.

Hi Anna,

Also try to code in the ONOPENFORM:

CurrForm.“My Control”.ACTIVATE;

Also play around the the properties SavePosAndSize, SourceTablePlacement, SaveValues, etc

The ACTIVATE is actually a good idea, the problem is that there is some native navision code executed afterwards.

What I have doen to overcome this was to create a new global of the type automation (Navision Timer) which I initialize in the OnOpenForm trigger,

In the event I deactivate the timer and call the ACTIVATE for another control there.

Mhmm… control numbering? Actually the control numbering follows the add-on numbering the changes are part of.

Anyway, I followed the opening of the form in debug - it looks as if the last object which is opened is the subform on the tab.

I already did this. It doesn’t work. [:(]

I’ll try… thank you for the suggestion.

Oh, another one.

When you export the main form as text, where do you find the “subform” ?

Actually the numbering of the controls is not of big interest for Navision. It is actually the order they appear in the text export.
Usually Navision activates the topmost one (If ActiveControlOnOpen is not defined).
Can you just try to “move” the subform control just to the end of the form controls (at the end of the page controls) or to the top?.

Er, forgive me. I’m not familiar with the functionality. What have I to do to instantiate the variable? [8-)]


I think I did what you suggested - included the export in text and move part - but it still doesn’t work… I’ll try more tomorrow. [:^)]

Define a new GLOBAL variable “NavTimer” or so, set type to Automation and select the Navision Timer 1.0 from the list provided when clicking the Sub Type and select “Timer” in the classes list, click OK. Show the properties of the new variable and set the “WithEvents” property to YES.


NavTimer.Interval := 100; // Set Timer to fire after 100ms
NavTimer.Enabled := TRUE; // Enable the timer to fire

Further down (last function in the C/AL code) you find to new functions:
NavTimer::Timer(Milliseconds : Integer)
NavTimer::TimerError(ErrorString : Text[1024])

In the first of these two triggers you put the following code:

NavTimer.Enabled := FALSE; // Prevents the timer from firing again

The idea behind this is that NAV runs some additional internal code to finanlize the creation of the subform AFTER the OnOpenForm trigger of the main form ran.
But as the timer trigger only fires AFTER NAV returns control to the user, we can be quite sure that the sub form initialization has been finished by then and our ACTIVATE really activates the control we want to have activated.

On the Sales Order properties change the SaveControlInfo to no

This will stop NAV from saving the last control the user was on when they closed the form, and always open the form on the first tab in the first control.

Thank you, John

the problem was exactly as Thomas described as well as the solution. Yesterday evening I was too tired and confused to make it work, but to morning I managed to make it work - exactly as Thomas said.

Interesting feature, isn’t it? [:)]

Thank you so much, Thomas. That was very clear, but I’m wondering - the form I was experimenting on is form 42 - Sales Order. Following the opening sequence in debug I saw that, after the code in form 42 OnOpenForm trigger, navision executed code in other linked forms triggers, included my subform.

My subfom has an higer control number than the lines subform but comes first in the form source… which might be the reason because the focus stopped on my subform instead on the lines subform as it normally does?

Might it be because my subform has code to be executed and form 46 has not?

Just mumbling…

This does not really matter. It must have something to do with the sub form as member of the tab control. When you would try to move the subform out of the tab control, you would see different behavior I guess.

Hey Anna

Try the following code in a form triggers,I hope it ll work.

Form - OnOpenForm()

Form - OnActivateForm()



Hi, Thiyagu

thank you for your suggestion. I’ve tried to implement it, since I hoped it would provide a solution without the use of automation, but I must have been missing something, since it doesn’t work.


Setting the DelayedInsert property of the subform to true will prevent this from occuring and foxus will be maintained on the main form. It has to be appropriate to do this though.


This worked a treat for me.

Hi Thomas,

That’s a pretty cool solution. Thanks for sharing this!

with best regards