Temporary Modification

tompynationtompynation Member Posts: 398
I have added a subform to the itemcard on a new Tab.

This subform contains a tablebox and a TextField where the user can enter a new integer value together with button

Enabled Field No. Field Name Data Type Length Description
Yes 1 ID Integer
Yes 2 ReceptID Integer
Yes 3 Regelnr Integer
Yes 4 ReceptItem Text 50
Yes 5 Hoeveelheid Decimal
Yes 6 Percentage Decimal

Yes 7 ExtraOmschrijving Text 150
Yes 8 ToonAlsVolumeJN Boolean
Yes 9 ToonTussentotaalJN Boolean

The fields in bold are shown in the tablebox.

Now when the user pressess the button, the table data should be changed
so that the Field Hoeveelheid, gets filled up with

[Percentage / (integer value entered by user)] * 100

This is no problem.

The problem is that this new Data for the Hoeveelheid field is temporary
More specific, if the user would go to another tab on the item form and then go back to the tab with this subform.

The tablebox should show the original value of the field 'Hoeveelheid'

How can i achieve this :?:

Comments

  • EugeneEugene Member Posts: 309
    do you ever need a new value of Hoeveelheid to be stored in the database or is it just and informative field ?
  • tompynationtompynation Member Posts: 398
    no the new value should never be stored, it's an informative field
  • EugeneEugene Member Posts: 309
    then you dont even need to create it as a field in the table.

    define a function in your form that will calculate the value then
    in your form you can put a textbox control and assign that function as its SourceExpr.

    when you enter yout tab you simply need to set to zero the integer value user probably has entered before
  • tompynationtompynation Member Posts: 398
    No, you dont understand what i mean...

    The field 'Hoeveelheid' already contains data,

    But when you press the button it should show the new calculated data.
    But this new calculated data should not be stored
  • EugeneEugene Member Posts: 309
    why dont you use a separate textbox to show the new data next to its old counterpart ?

    anyway you could write the function i mentioned in my previous post as follows:

    function GetTheValue:Decimal
    BEGIN
    IF (integer value entered by user) = 0 THEN
    EXIT(OldOriginalValue)
    ELSE
    EXIT([Percentage / (integer value entered by user)] * 100)
    END;
  • XypherXypher Member Posts: 297
    Have you tried using the OnFormat trigger of the textbox control within the table control?

    With this trigger you can interject with what you want shown rather than all/some/etc of the original data. (Without actually modifying the data)
  • DenSterDenSter Member Posts: 8,305
    No, you dont understand what i mean...

    The field 'Hoeveelheid' already contains data,

    But when you press the button it should show the new calculated data.
    But this new calculated data should not be stored
    So..... Hoeveelheid is a field in the table, and it contains data, but you don't want that data to be stored when it is changed on the form? That makes absolutely no sense to me at all.

    I think you don't understand what Eugene is suggesting, which is exactly what I would suggest as well. Create a function with a Decimal return value, and set that function as the SourceExpr of a textbox. If you want it to only load when a user hits a button then you need to set the textbox's SourceExpr as a global variable, and fill that variable when the button is clicked.

    There is not going to be any way that you can have the field in the table as the source of the textbox, and NOT storing any modified data back to the database.
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi tompynation,

    Just see the below object :wink:
    OBJECT Form 98765 test1
    {
      OBJECT-PROPERTIES
      {
        Date=07/25/08;
        Time=[ 7:48:59 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=20020;
        Height=7810;
        SourceTable=Table27;
        OnOpenForm=BEGIN
                        CurrForm.temp.VISIBLE(FALSE);
                   END;
    
      }
      CONTROLS
      {
        { 1102753003;TabControl;770;110 ;19030;5280 ;PageNamesML=ENU=Temp,222222,3333 }
        { 1102753004;TableBox;990 ;1100 ;18040;4070 ;ParentControl=1102753003;
                                                     InPage=0;
                                                     HeadingHeight=660 }
        { 1102753005;TextBox;0    ;5720 ;1700 ;440  ;ParentControl=1102753004;
                                                     InColumn=Yes;
                                                     SourceExpr="No.";
                                                     OnActivate=BEGIN
    
                                                                     CurrForm.temp.VISIBLE(SetCalculatedTempValue);
                                                                     CurrForm."Description 2".VISIBLE(NOT(SetCalculatedTempValue));
                                                                END;
                                                                 }
        { 1102753006;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753005;
                                                     InColumnHeading=Yes }
        { 1102753007;TextBox;1700 ;5720 ;1700 ;440  ;ParentControl=1102753004;
                                                     InColumn=Yes;
                                                     SourceExpr="No. 2" }
        { 1102753008;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753007;
                                                     InColumnHeading=Yes }
        { 1102753009;TextBox;3400 ;5720 ;4392 ;440  ;ParentControl=1102753004;
                                                     InColumn=Yes;
                                                     SourceExpr=Description }
        { 1102753010;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753009;
                                                     InColumnHeading=Yes }
        { 1102753014;TextBox;3360 ;2750 ;2530 ;440  ;Name=temp;
                                                     ParentControl=1102753004;
                                                     InColumn=Yes;
                                                     SourceExpr="No." + ' - ' + 'Temp' }
        { 1102753017;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753014;
                                                     InColumnHeading=Yes;
                                                     ForeColor=255;
                                                     CaptionML=ENU=Description 2 }
        { 1102753012;TextBox;4815 ;2750 ;4400 ;440  ;ParentControl=1102753004;
                                                     InColumn=Yes;
                                                     SourceExpr="Description 2";
                                                     OnFormat=BEGIN
    
    
    
                                                                  IF SetCalculatedTempValue THEN
                                                                  BEGIN
                                                                   It.RESET;
                                                                   IF It.FINDSET THEN
                                                                   REPEAT
                                                                     It."Description 2" := It."No." + '-' + 'AA';
                                                                   UNTIL It.NEXT = 0;
                                                                  END;
                                                              END;
                                                               }
        { 1102753013;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753012;
                                                     InColumnHeading=Yes }
        { 1102753025;TableBox;1100;1320 ;12320;3630 ;ParentControl=1102753003;
                                                     InPage=1;
                                                     HeadingHeight=880 }
        { 1102753026;TextBox;159  ;5500 ;1700 ;440  ;ParentControl=1102753025;
                                                     InColumn=Yes;
                                                     SourceExpr="Base Unit of Measure";
                                                     OnActivate=BEGIN
                                                                     SetCalculatedTempValue := FALSE;
                                                                END;
                                                                 }
        { 1102753027;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753026;
                                                     InColumnHeading=Yes }
        { 1102753028;TextBox;1859 ;5500 ;1700 ;440  ;ParentControl=1102753025;
                                                     InColumn=Yes;
                                                     SourceExpr="Price Unit Conversion" }
        { 1102753029;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753028;
                                                     InColumnHeading=Yes }
        { 1102753030;TextBox;3559 ;5500 ;1700 ;440  ;ParentControl=1102753025;
                                                     InColumn=Yes;
                                                     SourceExpr="Inventory Posting Group" }
        { 1102753031;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753030;
                                                     InColumnHeading=Yes }
        { 1102753018;TableBox;1100;1100 ;11880;3740 ;ParentControl=1102753003;
                                                     InPage=2;
                                                     HeadingHeight=770 }
        { 1102753019;TextBox;0    ;5280 ;2200 ;440  ;ParentControl=1102753018;
                                                     InColumn=Yes;
                                                     SourceExpr="Positive Adjmt. (LCY)";
                                                     OnActivate=BEGIN
                                                                    SetCalculatedTempValue := FALSE;
                                                                END;
                                                                 }
        { 1102753020;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753019;
                                                     InColumnHeading=Yes }
        { 1102753021;TextBox;2200 ;5280 ;2200 ;440  ;ParentControl=1102753018;
                                                     InColumn=Yes;
                                                     SourceExpr="Negative Adjmt. (LCY)" }
        { 1102753022;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753021;
                                                     InColumnHeading=Yes }
        { 1102753023;TextBox;4400 ;5280 ;2200 ;440  ;ParentControl=1102753018;
                                                     InColumn=Yes;
                                                     SourceExpr="COGS (LCY)" }
        { 1102753024;Label  ;0    ;0    ;0    ;0    ;ParentControl=1102753023;
                                                     InColumnHeading=Yes }
        { 1102753011;CommandButton;11330;6600;5060;550;
                                                     CaptionML=ENU=See Temp Values;
                                                     OnPush=BEGIN
                                                                 SetCalculatedTempValue := TRUE;
                                                                 CurrForm.temp.VISIBLE(SetCalculatedTempValue);
                                                                 CurrForm."Description 2".VISIBLE(NOT(SetCalculatedTempValue));
                                                            END;
                                                             }
      }
      CODE
      {
        VAR
          Math@1102753000 : Codeunit 50005;
          LogIn@1102753001 : Codeunit 1;
          WindowTitle@1102753002 : Text[50];
          HighestFolder@1102753003 : Text[500];
          ShellControl@1102753004 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{13709620-C279-11CE-A49E-444553540000}:'Microsoft Shell Controls And Automation'.Shell";
          Folder@1102753005 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{A7AE5F64-C4D7-4D7F-9307-4D24EE54B841}:'Microsoft Shell Controls And Automation'.Folder3";
          FolderText@1102753006 : Text[1024];
          Dur@1102753007 : Duration;
          date1@1102753008 : Date;
          date2@1102753009 : Date;
          ItRef@1102753010 : RecordRef;
          No2Ref@1102753011 : FieldRef;
          It@1102753012 : Record 27;
          fieldvalue@1102753013 : Variant;
          SetCalculatedTempValue@1102753014 : Boolean;
          calcvalue@1102753015 : Text[50];
    
        BEGIN
        END.
      }
    }
    

    I hope you got the solution ...... :P
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • XypherXypher Member Posts: 297
    Yeah Sandeep's example is by using the OnFormat trigger, which should do the trick.

    What tompynation I believe wants is the entire list of records with the temporary application of this format rather than just applying this to 1 textbox that contains only 1 value (the selected record's value).
Sign In or Register to comment.