Options

Subform depending on Variable [edit] and subform

aodaod Member Posts: 54
Hello again,

in my original Post i wanted to have a Subform depending on a Variable of the Main Form. Now I have to add a 2nd Subform depending on this Variable and a Field from the first Subform .. maybe somebody knows how to do that ? I tried but I failed !

Please help me.

Thanks.

_______________________
Original Post:

Hello,

I want to create a Form and a Subform Containing a "Price Key" for Items. This Key is different for any "Customer Price Group".

So I created a Main Form Item to selct the Item and wanted to add a Lookup Field (Variable of the Main Form) on "Customer Price Groups".

The Subform should now show the Records Matching to Item No. and Price Group (The Fields exist in Source Table and Subform).

Can anybody help me solcing this Problem ?

Thank you

Answers

  • Options
    Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi aod,

    Here are the sample objects for the query.... I hope it helps... O:)
    Please dont go for the alignment etc.....Just check the functionality. :)
    OBJECT Form 88888 Item main
    {
      OBJECT-PROPERTIES
      {
        Date=01/01/08;
        Time=[ 2:26:43 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=20680;
        Height=10890;
        SourceTable=Table27;
      }
      CONTROLS
      {
        { 1102753000;TabControl;220;220 ;16830;3960 ;HorzGlue=Both;
                                                     VertGlue=Both;
                                                     PageNamesML=ENU=General }
        { 1102753001;TextBox;3850 ;990  ;2750 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr="No." }
        { 1102753002;Label  ;440  ;990  ;3300 ;440  ;ParentControl=1102753001 }
        { 1102753003;TextBox;3850 ;1540 ;2750 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr="No. 2" }
        { 1102753004;Label  ;440  ;1540 ;3300 ;440  ;ParentControl=1102753003 }
        { 1102753005;TextBox;3850 ;2090 ;5500 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr=Description }
        { 1102753006;Label  ;440  ;2090 ;3300 ;440  ;ParentControl=1102753005 }
        { 1102753008;TextBox;11770;1980 ;2310 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr=EntryNo1;
                                                     TableRelation="Item Ledger Entry";
                                                     OnValidate=BEGIN
                                                                   IF (EntryNo1 <> 0) THEN
                                                                     CurrForm.sf.FORM.FilterOnEntryNo(EntryNo1);
                                                                END;
    
                                                     OnAfterValidate=BEGIN
                                                                          CurrForm.UPDATE(FALSE);
                                                                     END;
                                                                      }
        { 1102753007;SubForm;330  ;4400 ;12650;4070 ;Name=sf;
                                                     SubFormID=Form88881;
                                                     SubFormView=SORTING(Item No.,Posting Date)
                                                                 ORDER(Ascending);
                                                     SubFormLink=Item No.=FIELD(No.) }
      }
      CODE
      {
        VAR
          EntryNo1@1102753000 : Integer;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 88881 Item subform
    {
      OBJECT-PROPERTIES
      {
        Date=01/01/08;
        Time=[ 2:25:14 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=11770;
        Height=3630;
        TableBoxID=1102753000;
        SourceTable=Table32;
        OnActivateForm=BEGIN
                          SETRANGE("Entry No.",EntryNoGlobal);
                          CurrForm.UPDATE(FALSE);
                       END;
    
      }
      CONTROLS
      {
        { 1102753000;TableBox;0   ;0    ;11770;3630 ;HorzGlue=Both;
                                                     VertGlue=Both }
        { 1102753001;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Entry No.";
                                                     OnFormat=BEGIN
                                                                // IF (EntryNoGlobal <> 0) THEN
                                                                //   CurrForm."Entry No.".VISIBLE("Entry No." = EntryNoGlobal);
                                                                //   MESSAGE('Entry Type - OnFormat');
                                                                //   CurrForm."Entry No.".UPDATEFONTBOLD("Entry No." = EntryNoGlobal);
                                                              END;
                                                               }
        { 1102753002;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753001;
                                                     InColumnHeading=Yes }
        { 1102753005;TextBox;0    ;0    ;2057 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Entry Type" }
        { 1102753006;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753005;
                                                     InColumnHeading=Yes }
        { 1102753003;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Item No." }
        { 1102753004;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753003;
                                                     InColumnHeading=Yes }
        { 1102753007;TextBox;0    ;0    ;2200 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr=Quantity }
        { 1102753008;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753007;
                                                     InColumnHeading=Yes }
      }
      CODE
      {
        VAR
          ILE@1102753000 : Record 32;
          EntryNoGlobal@1102753001 : Integer;
    
        PROCEDURE FilterOnEntryNo@1102753000(EntryNo@1102753000 : Integer);
        BEGIN
          EntryNoGlobal := EntryNo;
          CurrForm.ACTIVATE;
        END;
    
        BEGIN
        END.
      }
    }
    
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Options
    aodaod Member Posts: 54
    Hi Sandeep Prajapati,

    thank you for your fast help - Sorry for my late reply. I have been in Meeting this morning.

    Seems to do exactly what I wanted to

    Thank you.
  • Options
    Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Its my pleasure that I could help. O:)
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Options
    aodaod Member Posts: 54
    Hello again,

    in my original Post i wanted to have a Subform depending on a Variable of the Main Form. Now I have to add a 2nd Subform depending on this Variable and a Field from the first Subform .. maybe somebody knows how to do that ? I tried but I failed !

    Please help me.

    Thanks.





    aod wrote:
    Hello,

    I want to create a Form and a Subform Containing a "Price Key" for Items. This Key is different for any "Customer Price Group".

    So I created a Main Form Item to selct the Item and wanted to add a Lookup Field (Variable of the Main Form) on "Customer Price Groups".

    The Subform should now show the Records Matching to Item No. and Price Group (The Fields exist in Source Table and Subform).

    Can anybody help me solcing this Problem ?

    Thank you
  • Options
    Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    I have to add a 2nd Subform depending on this Variable and a Field from the first Subform


    Could you please give an example. I am a bit not clear... :!:
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Options
    aodaod Member Posts: 54
    Ok I try to explain:

    I have a Mian Form with a Variable, that gets its content via Lookup from a Table and works as Filter for Subform1.

    At Subform1 there is field called "Group"

    Now I have to add a 2nd Subform.

    The content of the 2nd Subform should depend on 2 things:

    1. Variable from Mainform (or Subform1)
    2. The Field "Group" from Subform1
  • Options
    Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    hi aod,

    These r sample objects.... O:)
    Though they need some improvement .... basically they do what you need.
    OBJECT Form 88880 subform 2
    {
      OBJECT-PROPERTIES
      {
        Date=09/11/07;
        Time=[ 7:15:02 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=7150;
        Height=10010;
        TableBoxID=1102753000;
        SourceTable=Table5802;
        DelayedInsert=Yes;
        OnActivateForm=BEGIN
                         IF (GV_Location <> '') THEN
                         BEGIN
                           SETRANGE("Location Code",GV_Location);
                           SETRANGE("Item Ledger Entry Type",GV_EntryType);
                           IF FINDSET THEN;
    
                           CurrForm.UPDATE(FALSE);
                         END;
                       END;
    
      }
      CONTROLS
      {
        { 1102753000;TableBox;0   ;0    ;7040 ;10010;HorzGlue=Both;
                                                     VertGlue=Both;
                                                     HeadingHeight=770 }
        { 1102753001;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Location Code" }
        { 1102753002;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753001;
                                                     InColumnHeading=Yes }
        { 1102753003;TextBox;0    ;0    ;1880 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Item Ledger Entry Type" }
        { 1102753004;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753003;
                                                     InColumnHeading=Yes }
        { 1102753005;TextBox;0    ;0    ;2750 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     HorzAlign=Left;
                                                     SourceExpr="Item No." }
        { 1102753006;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753005;
                                                     InColumnHeading=Yes }
      }
      CODE
      {
        VAR
          GV_Location@1102753000 : Code[10];
          GV_EntryType@1102753001 : 'Purchase,Sale,Positive Adjmt.,Negative Adjmt.,Transfer,Consumption,Output, ';
          XmlDoc@1102753002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40";
    
        PROCEDURE FilterOn_Loc_And_EntryType@1102753000(Location@1102753000 : Code[10];EntryType@1102753001 : 'Purchase,Sale,Positive Adjmt.,Negative Adjmt.,Transfer,Consumption,Output, ');
        BEGIN
          GV_Location := Location;
          GV_EntryType := EntryType;
          CurrForm.ACTIVATE;
        END;
    
        PROCEDURE SetXMLDoc@1000000000(pXMLDoc@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40");
        BEGIN
          XmlDoc := pXMLDoc;
        END;
    
        PROCEDURE SendMessage@1000000002();
        BEGIN
          XmlDoc.loadXML('<root></root>');
        END;
    
        PROCEDURE GetText@1000000004() : Decimal;
        BEGIN
    
          //EXIT(vValue1+vValue2);  //----------to be pass to main form-----------
        END;
    
        EVENT XmlDoc@1102753002::ondataavailable@198();
        BEGIN
        END;
    
        EVENT XmlDoc@1102753002::onreadystatechange@-609();
        BEGIN
        END;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 88881 Item subform
    {
      OBJECT-PROPERTIES
      {
        Date=09/11/07;
        Time=[ 7:21:15 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=14850;
        Height=3960;
        SaveValues=Yes;
        InsertAllowed=Yes;
        TableBoxID=1102753000;
        SourceTable=Table32;
        DelayedInsert=Yes;
        OnActivateForm=BEGIN
                         IF (LocationGlobal <> '') THEN
                         BEGIN
                           SETRANGE("Location Code",LocationGlobal);
                           CurrForm.UPDATE(FALSE);
                         END;
                       END;
    
      }
      CONTROLS
      {
        { 1102753000;TableBox;0   ;0    ;13090;3630 ;Name=aaaaaa;
                                                     HorzGlue=Both;
                                                     VertGlue=Both;
                                                     Editable=Yes;
                                                     HeadingHeight=770 }
        { 1102753009;TextBox;503  ;880  ;1700 ;440  ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Location Code" }
        { 1102753010;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753009;
                                                     InColumnHeading=Yes }
        { 1102753001;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Entry No." }
        { 1102753002;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753001;
                                                     InColumnHeading=Yes }
        { 1102753005;TextBox;0    ;0    ;2057 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Entry Type";
                                                     OnBeforeInput=BEGIN
                                                                     SendMessage;
                                                                   END;
                                                                    }
        { 1102753006;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753005;
                                                     InColumnHeading=Yes }
        { 1102753003;TextBox;0    ;0    ;1700 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Item No." }
        { 1102753004;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753003;
                                                     InColumnHeading=Yes }
        { 1102753007;TextBox;0    ;0    ;2200 ;0    ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr=Quantity }
        { 1102753008;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753007;
                                                     InColumnHeading=Yes }
        { 1102753011;TextBox;7646 ;990  ;2530 ;440  ;ParentControl=1102753000;
                                                     InColumn=Yes;
                                                     SourceExpr="Document No." }
        { 1102753012;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753011;
                                                     InColumnHeading=Yes }
      }
      CODE
      {
        VAR
          ILE@1102753000 : Record 32;
          LocationGlobal@1102753001 : Code[10];
          XmlDoc@1102753002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40";
    
        PROCEDURE FilterOnLoc@1102753000(Location@1102753000 : Code[10]);
        BEGIN
          LocationGlobal := Location;
          CurrForm.ACTIVATE;
        END;
    
        PROCEDURE SetXMLDoc@1000000000(pXMLDoc@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40");
        BEGIN
          XmlDoc := pXMLDoc;
        END;
    
        PROCEDURE SendMessage@1000000002();
        BEGIN
          XmlDoc.loadXML('<root></root>');
        END;
    
        PROCEDURE GetText@1000000004() : Integer;
        BEGIN
    
          EXIT("Entry Type");  //----------to be pass to main form-----------
        END;
    
        EVENT XmlDoc@1102753002::ondataavailable@198();
        BEGIN
        END;
    
        EVENT XmlDoc@1102753002::onreadystatechange@-609();
        BEGIN
        END;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 88888 Item main
    {
      OBJECT-PROPERTIES
      {
        Date=09/11/07;
        Time=[ 7:32:15 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=20680;
        Height=17820;
        SourceTable=Table27;
        OnOpenForm=BEGIN
                     CREATE(XMLDoc);
                     CurrForm.sf.FORM.SetXMLDoc(XMLDoc);
                     //CurrForm.SF_ValueEntry.FORM.SetXMLDoc(XMLDoc);
                   END;
    
        OnCloseForm=BEGIN
                      CLEAR(XMLDoc);
                    END;
    
      }
      CONTROLS
      {
        { 1102753000;TabControl;220;220 ;16830;2640 ;HorzGlue=Both;
                                                     VertGlue=Both;
                                                     PageNamesML=ENU=General }
        { 1102753001;TextBox;3850 ;990  ;2750 ;440  ;Enabled=Yes;
                                                     Editable=Yes;
                                                     ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr="No." }
        { 1102753002;Label  ;440  ;990  ;3300 ;440  ;ParentControl=1102753001 }
        { 1102753003;TextBox;3850 ;1540 ;2750 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr="No. 2" }
        { 1102753004;Label  ;440  ;1540 ;3300 ;440  ;ParentControl=1102753003 }
        { 1102753005;TextBox;3850 ;2090 ;5500 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr=Description }
        { 1102753006;Label  ;440  ;2090 ;3300 ;440  ;ParentControl=1102753005 }
        { 1102753008;TextBox;13530;1980 ;2310 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr=Loc;
                                                     TableRelation=Location.Code;
                                                     OnValidate=BEGIN
                                                                   IF (Loc <> '') THEN
                                                                   BEGIN
                                                                     ILE.RESET;       // Calculating The Entry type for the first filtered line on applying lookup Location filter.
                                                                     ILE.SETRANGE("Item No.","No.");
                                                                     ILE.SETRANGE(ILE."Location Code",Loc);
                                                                     IF ILE.FINDFIRST THEN
                                                                       CurrForm.SF_ValueEntry.FORM.FilterOn_Loc_And_EntryType(Loc,ILE."Entry Type") //suboform2
                                                                     ELSE
                                                                       CurrForm.SF_ValueEntry.FORM.FilterOn_Loc_And_EntryType('!!!!!!!',ILE."Entry Type");
                                                                  // If there is no record found on the subform1 then make the subform2 also blank by filtering
                                                                  // for some non-existing locatioc code  in the navision, say - '!!!!!!!',
                                                                  // a not so clean trick.
    
                                                                     CurrForm.sf.FORM.FilterOnLoc(Loc);  // subform1
                                                                   END;
                                                                END;
    
                                                     OnAfterValidate=BEGIN
                                                                          CurrForm.UPDATE(FALSE);
                                                                     END;
                                                                      }
        { 1102753009;Label  ;10560;1980 ;2530 ;440  ;ParentControl=1102753000;
                                                     InPage=0;
                                                     CaptionML=ENU=Filter By Location }
        { 1102753012;TextBox;10560;1320 ;4730 ;440  ;Editable=No;
                                                     Focusable=Yes;
                                                     ParentControl=1102753000;
                                                     InPage=0;
                                                     SourceExpr=EntryType;
                                                     OnFormat=BEGIN
                                                                  CurrForm.SF_ValueEntry.FORM.FilterOn_Loc_And_EntryType(Loc,EntryType);
                                                              END;
                                                               }
        { 1102753007;SubForm;1210 ;3080 ;13530;4070 ;Name=sf;
                                                     Editable=Yes;
                                                     Focusable=Yes;
                                                     SubFormID=Form88881;
                                                     SubFormView=SORTING(Item No.,Posting Date)
                                                                 ORDER(Ascending);
                                                     SubFormLink=Item No.=FIELD(No.) }
        { 1102753010;SubForm;6710 ;7920 ;7150 ;8030 ;Name=SF_ValueEntry;
                                                     Editable=Yes;
                                                     SubFormID=Form88880 }
        { 1102753011;Label  ;1540 ;11000;4730 ;550  ;ForeColor=0;
                                                     FontBold=Yes;
                                                     CaptionML=ENU=Value Entry (Loc + Entry Type) }
      }
      CODE
      {
        VAR
          Loc@1102753000 : Code[10];
          ILE@1102753001 : Record 32;
          XMLDoc@1102753002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{88D969C0-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v4.0'.DOMDocument40" WITHEVENTS;
          EntryType@1102753003 : 'Purchase,Sale,Positive Adjmt.,Negative Adjmt.,Transfer,Consumption,Output, ';
    
        EVENT XMLDoc@1102753002::ondataavailable@198();
        BEGIN
        END;
    
        EVENT XMLDoc@1102753002::onreadystatechange@-609();
        BEGIN
          IF (XMLDoc.readyState = 4) THEN BEGIN
            EntryType := CurrForm.sf.FORM.GetText();
            CurrForm.UPDATE(FALSE);
          END;
        END;
    
        BEGIN
        END.
      }
    }
    


    I hope it helps. ... :P
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Options
    aodaod Member Posts: 54
    Thank you Sandeep Prajapati again,

    I will have no time to test this today .. but I am sure that it will work - like the first solution :D .

    If I have tested I will post again ...
  • Options
    aodaod Member Posts: 54
    ... works perfect ! Thank you ...
  • Options
    Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    I know, that is not perfect. Still If that solves your problem.... I am really happy. ... :P
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
Sign In or Register to comment.