OBJECT Form 50000 Test { OBJECT-PROPERTIES { Date=06/04/07; Time=17:04:35; Modified=Yes; Version List=; } PROPERTIES { Width=3300; Height=2420; OnOpenForm=BEGIN CurrForm.Sub.FORM.SetCuRef(commcuref); END; OnCloseForm=BEGIN CLEAR(commcuref); END; } CONTROLS { { 1000000000;TextBox;110 ;110 ;3080 ;880 ;FontName=Courier; FontSize=18; FontBold=Yes; SourceExpr=count } { 1000000001;SubForm;110 ;1100 ;3080 ;1210 ;Name=Sub; Border=No; SubFormID=Form50005 } } CODE { VAR count@1000000000 : Integer; commcuref@1000000001 : Codeunit 50000; PROCEDURE DoIt@1000000000(); BEGIN count += 1; CurrForm.UPDATE(FALSE); END; PROCEDURE SetCuRef@1000000002(curef@1000000000 : Codeunit 50000); BEGIN commcuref := curef; END; BEGIN END. } } OBJECT Form 50001 Test2 { OBJECT-PROPERTIES { Date=06/04/07; Time=17:05:00; Modified=Yes; Version List=; } PROPERTIES { Width=3300; Height=2420; OnOpenForm=BEGIN CurrForm.Sub.FORM.SetCuRef(commcuref); END; OnCloseForm=BEGIN CLEAR(commcuref); END; } CONTROLS { { 1000000000;TextBox;110 ;1430 ;3080 ;880 ;FontName=Courier; FontSize=18; FontBold=Yes; SourceExpr=count } { 1000000001;SubForm;110 ;110 ;3080 ;1210 ;Name=Sub; Border=No; SubFormID=Form50005 } } CODE { VAR count@1000000000 : Integer; commcuref@1000000001 : Codeunit 50000; PROCEDURE DoIt@1000000000(); BEGIN count -= 1; CurrForm.UPDATE(FALSE); END; PROCEDURE SetCuRef@1000000002(curef@1000000000 : Codeunit 50000); BEGIN commcuref := curef; END; BEGIN END. } } OBJECT Form 50002 Test3 { OBJECT-PROPERTIES { Date=06/04/07; Time=17:16:02; Modified=Yes; Version List=; } PROPERTIES { Width=3300; Height=1760; OnCloseForm=BEGIN CLEAR(commcuref); END; } CONTROLS { { 1000000000;TextBox;110 ;110 ;3080 ;880 ;FontName=Courier; FontSize=18; FontBold=Yes; SourceExpr=count } { 1000000002;CommandButton;110;1100;3080;550;Name=Run; OnPush=BEGIN OtherForm.SetCuRef(commcuref); OtherForm.RUN; END; } } CODE { VAR count@1000000000 : Integer; commcuref@1000000001 : Codeunit 50000; OtherForm@1000000002 : Form 50005; PROCEDURE DoIt@1000000000(); BEGIN count += 1; CurrForm.UPDATE(FALSE); END; PROCEDURE SetCuRef@1000000002(curef@1000000000 : Codeunit 50000); BEGIN commcuref := curef; END; BEGIN END. } } OBJECT Form 50005 SubTest { OBJECT-PROPERTIES { Date=06/04/07; Time=16:56:15; Modified=Yes; Version List=; } PROPERTIES { Width=3080; Height=1100; OnCloseForm=BEGIN CLEAR(commcuref); END; } CONTROLS { { 1000000000;CommandButton;0;0 ;3080 ;1100 ;Name=Update; FontName=Aerial; FontSize=18; FontBold=Yes; OnPush=BEGIN commcuref.DoIt(); END; } } CODE { VAR commcuref@1000000000 : Codeunit 50000; PROCEDURE SetCuRef@1000000002(curef@1000000000 : Codeunit 50000); BEGIN commcuref := curef; END; BEGIN END. } } OBJECT Form 50010 FormLauncher { OBJECT-PROPERTIES { Date=06/04/07; Time=16:30:56; Modified=Yes; Version List=; } PROPERTIES { Width=440; Height=330; Visible=No; OnInit=BEGIN RunFormNo := 1; END; OnOpenForm=BEGIN formcu.SetCuRef(formcu); formcu.RunForm(RunFormNo); formcu.RUN; CLEAR(formcu); CurrForm.CLOSE; END; OnHyperlink=VAR EPos@1000000001 : Integer; BEGIN EPos := STRPOS(URL,'VARIABLE=') + 9; EVALUATE(RunFormNo,COPYSTR(URL,EPos,(STRLEN(URL) - EPos) + 1)); END; } CONTROLS { } CODE { VAR formcu@1000000000 : Codeunit 50000; RunFormNo@1000000001 : Integer; PROCEDURE RunForm@1000000001(FormNo@1000000000 : Integer); BEGIN RunFormNo := FormNo; END; BEGIN END. } } OBJECT Codeunit 50000 FormCommunicator { OBJECT-PROPERTIES { Date=06/04/07; Time=16:51:57; Modified=Yes; Version List=; } PROPERTIES { SingleInstance=No; OnRun=BEGIN CASE RunFormNo OF 1: BEGIN tform.SetCuRef(commcuref); tform.RUNMODAL(); END; 2: BEGIN tform2.SetCuRef(commcuref); tform2.RUNMODAL(); END; 3: BEGIN tform3.SetCuRef(commcuref); tform3.RUNMODAL(); END; END; END; } CODE { VAR tform@1000000001 : Form 50000; tform2@1000000003 : Form 50001; tform3@1000000004 : Form 50002; RunFormNo@1000000002 : Integer; commcuref@1000000000 : Codeunit 50000; PROCEDURE SetCuRef@1000000002(curef@1000000000 : Codeunit 50000); BEGIN commcuref := curef; END; PROCEDURE DoIt@1000000000(); BEGIN CASE RunFormNo OF 1: tform.DoIt(); 2: tform2.DoIt(); 3: tform3.DoIt(); END; END; PROCEDURE RunForm@1000000001(FormNo@1000000000 : Integer); BEGIN RunFormNo := FormNo; END; BEGIN END. } } OBJECT MenuSuite 90 Company { OBJECT-PROPERTIES { Date=06/04/07; Time=17:07:15; Modified=Yes; Version List=; } PROPERTIES { } MENUNODES { { ;[{28B406BE-DD89-43EC-B2B9-6BB90DC2583B}] ;NextNodeID=[{E1094594-64FB-4AEC-9963-3C4363A6F43B}] } { MenuShortcut ;[{E1094594-64FB-4AEC-9963-3C4363A6F43B}] ;Name=Test; CaptionML=ENU=Run Form One; MemberOfMenu=[{19A352FE-D90D-424E-B85F-CF3B8E98CF0E}]; ParentNodeID=[{19A352FE-D90D-424E-B85F-CF3B8E98CF0E}]; ShortcutURL=navision:/ /client/run?target=Form%2050010%26MYVARIABLE=1; Visible=Yes; NextNodeID=[{334E0A3B-9E47-4D5C-A8FC-B5E22546DD65}] } { MenuShortcut ;[{334E0A3B-9E47-4D5C-A8FC-B5E22546DD65}] ;Name=Test2; CaptionML=ENU=Run Form Two; MemberOfMenu=[{19A352FE-D90D-424E-B85F-CF3B8E98CF0E}]; ParentNodeID=[{19A352FE-D90D-424E-B85F-CF3B8E98CF0E}]; ShortcutURL=navision:/ /client/run?target=Form%2050010%26MYVARIABLE=2; Visible=Yes; NextNodeID=[{6BAF36FB-1A5F-4FD3-AE6E-EE837F5CBB99}] } { MenuShortcut ;[{6BAF36FB-1A5F-4FD3-AE6E-EE837F5CBB99}] ;Name=Test2; CaptionML=ENU=Run Form Three; MemberOfMenu=[{19A352FE-D90D-424E-B85F-CF3B8E98CF0E}]; ParentNodeID=[{19A352FE-D90D-424E-B85F-CF3B8E98CF0E}]; ShortcutURL=navision:/ /client/run?target=Form%2050010%26MYVARIABLE=3; Visible=Yes; NextNodeID=[{00000000-0000-0000-0000-000000000000}] } } }
Comments
"navision://"
to
"navision:/ /"
otherwise it takes it as a comment. Then delete the space in the Nav Pane Designer.
I've added the space into the original code text export.
This question has been asked so many times, with the previous solutions very poor indeed.
With this you can not only get a sub-form to directly update its parent/header at will but also build seriously powerful user interfaces.
Ah well, maybe I should get a moderator to delete this thread and keep this little gem all to myself.
With the Easter-weekend, I don't think a lot of people were still thinking about Navision or at least not eager to dive into your code (I tried Friday but quickly decided to look at it again AFTER the weekend :roll: )
Now I got the overall idea.
It does solve the ontimer problem for sending data from the subform to the mainform.
The negative is that it includes some programming.
For improving your system: wouldn't it be better to use a single instance codeunit? This you initialize at the open of a company and it remains open from then on. So when you need to open a form, you can just call a function in the codeunit from another object that after the call you can close again.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
You could do, yes, I posted this to try to get some feedback on the best way to configure the system. As I said, it's just an idea I had on how to exploit the passing of a codeunit used as a wrapper reference to forms.
I've been playing with it a little more, you can get subforms to directly update other subforms, it's quite powerful. I'd just like people to have a play with it and give their opinions on the best way to configure it.
The only problem with it that I cannot work out at the moment (the way I have it configured) is that when running, for some reason, you cannot hide or show the Navigation Panel, but you can when the form is closed. :-k
If anyone has an idea of why this maybe the case, it would be much appreciated.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
It doesn't lock the object designer, it doesn't lock the Navigation Panel, it just disables the ability to show/hide the Navigation Panel.
I will continue to try and find the solution. It has something to do with the object FormLauncher.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!