changing the current record ...

deepbluedeepblue Member Posts: 152
Hello,

I want to change the current record in an opened form from an another form. I used the following code but it doesn't work :( : in form1, I wrote
      RecExemple.RESET;
      RecExemple.GET(Val1,Val2);
      Form2.SETTABLEVIEW(RecExemple);
      Form2.SETRECORD(RecExemple);
      Form2.UPDATECONTROLS;
      CurrForm.CLOSE;
What should I do?

Thank you!!!

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I don;t know the purpose of this functionality but to begin with you do not run the 2nd form.
    Form2.RUN
    
  • deepbluedeepblue Member Posts: 152
    The 2end form is already opened!!!!
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Ah. I understand.

    So you want to forms to look at the same record independent from each other?

    I remember an other post about this. Wait while I search please :mrgreen:
  • David_CoxDavid_Cox Member Posts: 509
    RecExemple.RESET;
    RecExemple.SETRANGE(Val1,Val1);
    RecExemple.SETRANGE(Val2,Val2);
    // MODAL = Wait till I close Form 2 then close Form 1
    FORM.RUNMODAL(FORM::"Form 2",RecExample);
    CurrForm.CLOSE;
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    I cannot find the old post. :|

    What do you exactly want to achieve with the 2 forms. Maybe if you explain the functionality we can figure out a technical solution for it.
  • deepbluedeepblue Member Posts: 152
    I want to the form2 displays the record (Val1,Val2), values are calculated in form1. and after that to close form1
  • David_CoxDavid_Cox Member Posts: 509
    deepblue wrote:
    The 2end form is already opened!!!!

    Ah this is no easy, as the form is already open, and you cannot pass the focus to the open form, while form 1 is open.

    The only way is use a single instance codeunit, post some values to it then close form 1, there has been a post on the codeunit it today.

    On the form 2, add a Timer Event check if the code unit has a value different from the displayed record, if it has then update the form, any other idea's?
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • hedegaardhedegaard Member Posts: 25
    edited 2006-05-31
    You should declare form2 as a variable.

    In form2 you make a new function.
    In the function you put code like:

    IF FIND('+') THEN;
    CurrForm.Update(false);


    In form1 you make a call to the function in form2 and it will update.

    If form2 contains a temporary record you will need to trigger the correct action directly in OnFindRecord.

    NB: It might require you open form2 using runmodal. This might not fit your requirement.

    good luck
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    David Cox wrote:
    deepblue wrote:
    The 2end form is already opened!!!!

    Ah this is no easy, as the form is already open, and you cannot pass the focus to the open form, while form 1 is open.

    The only way is use a single instance codeunit, post some values to it then close form 1, there has been a post on the codeunit it today.

    On the form 2, add a Timer Event check if the code unit has a value different from the displayed record, if it has then update the form, any other idea's?

    This is indeed the direction in which to proceed.

    Please remember this is not a recomendable solution. Try to convince your customer to use a solution that is more suitable with navisions technical possibilities.
Sign In or Register to comment.