Problem in Form!!!

WarfoxWarfox Member Posts: 53
edited 2004-05-21 in Navision Attain
Hello all,

i have got an problem in a form, i want the onaftergetrecord trigger to run only once on opening the form, but later when you scroll through your lines it should run every time.

THX 4 Help

Comments

  • kinekine Member Posts: 12,562
    you cannot change when... What do you want to do?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • micheldoggermicheldogger Member Posts: 21
    Maybe you can use a global variable wich you set when your code
    has run once. The code will only run when it's false (Boolean is default False), after the code has run you set the variable on true, so it won't run again.
  • WarfoxWarfox Member Posts: 53
    But when will i change back the boolean?
  • kinekine Member Posts: 12,562
    WHAT DO YOU WANT TO DO??? Without details I cannot help you... OnAfterGetRecord is called when row is read from DB. On open form is for each row in cache, after scrolling for each new record etc.... why you need to call it only once? Why do you need to call it after that?????? :?: :?: :?: Still too much question without answers... :?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WarfoxWarfox Member Posts: 53
    It´s hard to describe, but i´ll try. I have got an array which i have to fill with the first record on the table when the form is opened. Later, when the user scrolls in the record, i have to modify the array again and again.
    But i have nearly solved the problem...
  • kinekine Member Posts: 12,562
    the array is something as record history? What do you mean with "the user scrolls in the record"? it means, that user select this record again? What you change in array? Why not use OnAfterGetCurrentRecord? :(

    I am still asking, I know, but my brain is working and there are many solutions for many things... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • RobertMoRobertMo Member Posts: 484
    Like kine said. If you need a solution or at least a lot of (good) ideas, it's better to describe what do you really want to achieve.

    Sometimes a man cannot see a solution because he's looking to close.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • WarfoxWarfox Member Posts: 53
    In fact it doesn´t matter what i want to do, because that what i want to do with the array works perfectliy, what i need is an idea how i can run the code in the on aftergetrecord trigger once, when i open the form. Because there are displayed 4 records in the the list, so the on aftergetrecord is executed 4 times, so the pointer is on the first record of the list and the according data in the array is for the last record in the list. Because i fill the array in the on aftergetrecord.

    The programm is too complex for describing it here, sorry.
  • oleschjoetholeschjoeth Member Posts: 74
    I will join the rest of the guys who answered you, Warfox. Simply use a global variable on the form e.g. a boolean. Set it to true the first time you retrieve the record and set up a if-condition for the rest of your trigger code based on that boolean. The value of the variable lives as long as the form lives.

    Regards,
    Ole
  • kinekine Member Posts: 12,562
    If you only need to have last record in Array, why not do "
      MyRec.COPY(Rec);
      MyRec.FIND('+');
      array blablablablabla..... //there can I do something with last rec in form...
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • WarfoxWarfox Member Posts: 53
    thx oleschjoeth, but can you tell me on which trigger i have to set the boolean back. No kine i have to need the first record, but with a find ('-') it doesn´t work *g* i have nearly solved the problem by using an integer counter but it doesn´t work perfectly.
  • kinekine Member Posts: 12,562
    Still, i have no information to be able help you. If you can't tell us what do you want to do, I am not able to help you. I can only guess the answer for your question...

    sorry

    :( :?:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • oleschjoetholeschjoeth Member Posts: 74
    Warfox, why would you want to set it back? As Kine says, if you don't want to tell us what you are trying to achieve it's very difficult to help you. Me might suggest a solution that won't work for you because we see your problem out of context due to your lack of information :)

    Ole
  • Timo_LässerTimo_Lässer Member Posts: 481
    Try to put your code in the OnAfterGetCurrRecord-Trigger.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • WarfoxWarfox Member Posts: 53
    hy, good news, i´ve solved it.
    It was a little bit difficult, but here is the code:

    Form - OnopenForm
    openform := TRUE;
    counter2 := 0;
    records := 4; //The records that can be shown in the form at one time


    Form - OnAfterGetRecord()
    CALCFIELDS(Splittcount);
    CALCFIELDS("Finished Positions");
    CALCFIELDS("Position Finished");
    counter2 := counter2 + 1;
    IF (counter2 = 1) OR (openform = FALSE) THEN BEGIN
    FOR counter := 1 TO 4 DO BEGIN
    Split.RESET;
    Split.SETRANGE("Picknr.","Picknr.");
    Split.SETRANGE("Zeilennr.","Zeilennr.");
    Split.SETRANGE("Fachnr.", STRSUBSTNO('%1',counter));
    IF Split.FIND('-') THEN BEGIN
    Amount[counter][1] := Split.Menge;
    IF Split.Menge = 0 THEN
    Amount[counter][1] := Split."Bestellte Menge";
    Amount[counter][2] := Split."Bestellte Menge";
    Textfield[counter][1] := STRSUBSTNO('%1',Amount[counter][1]);
    Textfield[counter][2] := STRSUBSTNO('Filiale:\%1',Split.Filliale);
    END ELSE BEGIN
    Amount[counter][1] := 0;
    Amount[counter][2] := 0;
    Textfield[counter][1] := STRSUBSTNO('%1',Amount[counter][1]);
    Textfield[counter][2] := '';
    END;
    END;
    END;
    IF counter2 >= records THEN
    openform := FALSE;
Sign In or Register to comment.