tab order

Hi all,

this request i have been asked in other discussions groups,

I have got some suggestion, but they don’t resolved my problem.

////////////////////////////////////////////

I need to change tab order of the controls on form dynamicly(runtime).

I used CurrForm.“Field Name”.ACTIVATE function.

but when i call this function in the “XXX - OnDeactivate()” trigger i

get an error:


Microsoft Business Solutions-Navision


There is insufficient memory (stack) to execute this function.

This can be due to the way that recursive function calls are used in

the program. Contact your system manager if you need assistance.


OK


But calling of this function in the other triggers don’t cause an error.

Any assistance how I can resolve my problem may be helpful.

I have struggled with things like this before also, i have often solved this issue by coding the cursor movements via Windows Scripting Host.

This may be an option for you to look at.

I haven’t experience with scripting host, can you say where can I find detailed info??

Like most things in Navision, this is a pretty simple thing to do, you just need to look at it from a difernt perspective.

basically I guess you are trying to set up some paramaters, and based on these, send the cursor to a different field. So …

Create a new function GoToNextField;
Create a variable LastFieldNo and TmpLastFieldNo integers

The function will be something like:

Tmplastfieldno := lastfieldno;
lastfieldno := 0;
Case LastFieldNo of
1000 : CurrForm.Description.ACTIVATE;
2000 : CurrForm.MyControl.ACTIVATE;
4400 : CurrForm.Someothercontrol.ACTIVATE;
end;

Now in the field that the user needs to be in,set the porperty NextControl to point to a new dummy control. This will be a control hidden ont he form somewhere and not used. Call it GoToControl
Also in the Activate Trigger add the code

LastFieldNo := 2000; // paramater is the number of the current control

In the control GoToControl, add the follwoing code in the on activate trigger add:

GoToNextField;

Should work fine.

OK, that is hard to understand … [:O]

I will create a form and upload it as an example, that will be easier to understand. [<:o)]

Thank you it’s understandable for me, good idea.

but it not works, every time focus goes to the next textbox I specified. If have time please, make *.txt file from code bellow, and import to the navision and see how I did.

I cant find any way to attach my form in Fob format.

Thank you

OBJECT Form 77776 Test tab orders
{
OBJECT-PROPERTIES
{
Date=06/12/06;
Time=[ 2:43:58 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
Width=17050;
Height=4400;
SourceTable=Table18;
OnAfterGetCurrRecord=BEGIN
CurrForm.“Search Name”.ENABLED := (“No.” <> ‘10000’);
END;

}
CONTROLS
{
{ 1100795000;TabControl;220;220 ;16610;3300 ;HorzGlue=Both;
VertGlue=Both;
PageNamesML=ENU=General }
{ 1100795014;TextBox;15730;1100 ;220 ;400 ;ParentControl=1100795000;
InPage=0;
SourceExpr=GoToControl;
OnActivate=BEGIN
GoToNextControl;
END;
}
{ 1100795015;TextBox;3850 ;1100 ;2750 ;440 ;ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“No.”;
OnActivate=BEGIN
LastControlID := 1100795015;
END;
}
{ 1100795016;Label ;440 ;1100 ;3300 ;440 ;ParentControl=1100795015 }
{ 1100795017;TextBox;10890;1100 ;4620 ;440 ;ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=Name;
OnActivate=BEGIN
LastControlID := 1100795017;
END;
}
{ 1100795018;Label ;9460 ;1100 ;1320 ;440 ;ParentControl=1100795017 }
{ 1100795019;TextBox;3850 ;1650 ;2750 ;440 ;ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“Search Name”;
OnActivate=BEGIN
LastControlID := 1100795019;
END;
}
{ 1100795020;Label ;440 ;1650 ;3300 ;440 ;ParentControl=1100795019 }
{ 1100795021;TextBox;3850 ;2200 ;5500 ;440 ;ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“Name 2”;
OnActivate=BEGIN
LastControlID := 1100795021;
END;
}
{ 1100795022;Label ;440 ;2200 ;3300 ;440 ;ParentControl=1100795021 }
{ 1100795023;TextBox;10890;2200 ;4620 ;440 ;ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=Address;
OnActivate=BEGIN
LastControlID := 1100795023;
END;
}
{ 1100795024;Label ;9460 ;2200 ;1320 ;440 ;ParentControl=1100795023 }
{ 1100795025;TextBox;3850 ;2750 ;5500 ;440 ;ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“Address 2”;
OnActivate=BEGIN
LastControlID := 1100795025;
END;
}
{ 1100795026;Label ;440 ;2750 ;3300 ;440 ;ParentControl=1100795025 }
{ 1100795013;CommandButton;14520;3630;2200;550;
Name=Help;
HorzGlue=Right;
VertGlue=Bottom;
PushAction=FormHelp }
}
CODE
{
VAR
LastControlID@1100795000 : Integer;
TmpLastControlID@1100795001 : Integer;
GoToControl@1100795002 : Integer;

PROCEDURE GoToNextControl@1100795001() : Integer;
BEGIN
TmpLastControlID := LastControlID;
LastControlID := 0;

CASE TmpLastControlID OF
1100795015:
CurrForm.Name.ACTIVATE;
1100795017:
IF “No.” = ‘10000’ THEN
CurrForm.“Name 2”.ACTIVATE
ELSE
CurrForm.“Search Name”.ACTIVATE;
1100795019:
CurrForm.“Name 2”.ACTIVATE;
1100795021:
CurrForm.Address.ACTIVATE;
1100795023:
CurrForm.“Address 2”.ACTIVATE;
1100795025:
CurrForm.Help.ACTIVATE;
END;
END;

BEGIN
END.
}
}

Two things -

Are you using a list form - If so, you MIGHT hsve to activate the control in front of it - Not sure why - I just know I have had to do that a lot of times.

I useally place the code on the OnAfterValidate trigger - and have had no problems with that.

Let me know

no, I’m using card form, i’m surprised why it not worked.

OnAfterValidate not works, it only works when user changes controls value.

Hi Samson

Did you manage to find an answer to your problem of…

There is insufficient memory (stack) to execute this function.

Cheers

David

Hi Samson,

I’ve played with the object you uploaded. Its here as text. I could also not get it to work until I set the GoToControl to visible false.

Heres the code, have a look at the changes. Try working from that, let us all know if it works.

OBJECT Form 77776 Test tab orders
{
OBJECT-PROPERTIES
{
Date=12/07/06;
Time=[ 9:50:58];
Modified=Yes;
Version List=;
}
PROPERTIES
{
Width=17050;
Height=7700;
SourceTable=Table18;
OnOpenForm=BEGIN
LastControlID := 0;
GoToNextControl;
END;

}
CONTROLS
{
{ 1100795000;TabControl;220;220 ;16610;6600 ;HorzGlue=Both;
VertGlue=Both;
PageNamesML=ENU=General }
{ 1100795014;TextBox;11770;990 ;2860 ;550 ;Name=GoToNextControlCTL;
Visible=No;
ParentControl=1100795000;
InPage=0;
SourceExpr=GoToControl;
OnActivate=BEGIN
GoToNextControl;
END;
}
{ 1100795015;TextBox;3850 ;1100 ;2750 ;440 ;Name=No.;
ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“No.”;
OnActivate=BEGIN
LastControlID := 100;
END;
}
{ 1100795016;Label ;440 ;1100 ;3300 ;440 ;ParentControl=1100795015 }
{ 1100795017;TextBox;3850 ;1650 ;2640 ;440 ;Name=Name;
ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=Name;
OnActivate=BEGIN
LastControlID := 200;
END;
}
{ 1100795018;Label ;440 ;1650 ;3300 ;440 ;ParentControl=1100795017 }
{ 1100795019;TextBox;3850 ;2200 ;2750 ;440 ;Name=Search Name;
ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“Search Name”;
OnActivate=BEGIN
LastControlID := 300;
END;
}
{ 1100795020;Label ;440 ;2200 ;3300 ;440 ;ParentControl=1100795019 }
{ 1100795021;TextBox;3850 ;2750 ;5500 ;440 ;Name=Name 2;
ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“Name 2”;
OnActivate=BEGIN
LastControlID := 400;
END;
}
{ 1100795022;Label ;440 ;2750 ;3300 ;440 ;ParentControl=1100795021 }
{ 1100795023;TextBox;3850 ;3300 ;2640 ;440 ;Name=Address;
ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=Address;
OnActivate=BEGIN
LastControlID := 500;
END;
}
{ 1100795024;Label ;440 ;3300 ;3300 ;440 ;ParentControl=1100795023 }
{ 1100795025;TextBox;3850 ;3850 ;5500 ;440 ;Name=Address 2;
ParentControl=1100795000;
InPage=0;
NextControl=1100795014;
SourceExpr=“Address 2”;
OnActivate=BEGIN
LastControlID := 600;
END;
}
{ 1100795026;Label ;440 ;3850 ;3300 ;440 ;ParentControl=1100795025 }
{ 1100795013;CommandButton;14630;6930;2200;550;
Name=Help;
HorzGlue=Right;
VertGlue=Bottom;
PushAction=FormHelp }
}
CODE
{
VAR
LastControlID@1100795000 : Integer;
LastControlID2@1101353000 : Integer;
TmpLastControlID@1100795001 : Integer;
GoToControl@1100795002 : Integer;

PROCEDURE GoToNextControl@1100795001();
BEGIN
//No. 100
//name 200
//S. Name 300
//Name 2 400
//address 500
//Address 2 600

TmpLastControlID := LastControlID;
LastControlID := 0;

CASE TmpLastControlID OF
0 : CurrForm.“No.”.ACTIVATE;
100 : CurrForm.Name.ACTIVATE;
200 : CurrForm.“Search Name”.ACTIVATE;
300 : CurrForm.“Name 2”.ACTIVATE;
400 : CurrForm.Address.ACTIVATE;
500 : CurrForm.“Address 2”.ACTIVATE;
600 : CurrForm.Help.ACTIVATE;
END;
END;

BEGIN
END.
}
}

Hi Samson,

My colleague here recommends increasing the DBMS Cache on the machine if the problem occures again.

Hope this helps

Cheers

David

It is very unlikely that this will solve the issue here. The issue is a design problem wher ean infintie loop is created. Firstly it is created localy on the client, so its probably the local cache that will help, nort server cacehe, but even if you increase cache, that will jsut mean it will take longer to fill the ceche before the error is triggered.

The solution is to redesign the code as I suggested in the begining.

Hi David,

thank you for answers, but neither first nor second suggestion doesn’t work.

for second suggestion, I was do as you described, but it is not worked correctly. I have been upload my test form in txt format, if you have a time, please look at it. In my example, Name field after getting focus immediately loses it, user can not see this process, I saw it just by debuging.

Thanks more,

Samson

Hi Tony,

I’ve import txt file you sent, but it is not what I need.

First i need to situate fields in 2 columns,

Example

AAA BBB

CCC

DDD EEE

and tab order must be AAA,BBB,CCC,DDD,EEE

In some reason CCC field must be disabled, in this case Navision moves focus from BBB to the EEE field(as they in same column), but if CCC is disabled I need to go DDD before EEE.

And secondly your code is not worked because of GoToControl textbox is unvisible and can not got focus, therefore it cannot run GoToNextControl; function.

anyway thank you very much,

Samson

Hi Samson,

I’ll have a look at this over the weekend and try and get a working solution to you by Monday.

Its 3pm friday for me, nearly time for the weekend [:)]

Tony