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
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
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;
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
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.
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?
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
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
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.