How to close a Form defined as a variable....

NRNR Member Posts: 78
In the Form "Payment Journal",
I have created a Global Variable "GLReconcile" with Datatype as Form and Subtype as "Reconciliation"

I have added a Menu Item in the Payment Journal which triggers the form through the following C/AL
GLReconcile.RUN;

After the form has been executed, I want to close this form which has been run by using the C/AL .

My query is how can I close this Variable "GLReconcile",as there is no function "Close" for this variable.

Thanks in advance.

Comments

  • bbrownbbrown Member Posts: 3,268
    If I understand your question, you want to open a form from code. Then do some processing and have the code close the form. Right?

    Try the following:

    1. Create a function on the form:

    CloseForm:
    CurrForm.CLOSE

    2. Call this function from your code.
    There are no bugs - only undocumented features.
  • NRNR Member Posts: 78
    Thanks for the reply.

    I followed the solution stated by you, but it gives an error "The form is not open"

    I ll tell you exactly in which form I am getting stuck
    Payment Journal > Posting > Reconcile.

    Here, Reconcile Form is opened from a C/AL code from within the Payment Journal.
    I am using this form for some other functionality also, and hence I want to close the Reconcile Form from Payment Journal.

    Kindly advice.....
  • krikikriki Member, Moderator Posts: 9,118
    NR wrote:
    I followed the solution stated by you, but it gives an error "The form is not open"
    This is because you open the form as form.RUN. This continues immediately the next command and doesn't wait for the form to open. And probably you send run the function to close the form BEFORE the form has had the time to open.
    So you should put a SLEEP after the form.RUN.
    This way the form has the time to open. (I think this helps but I am not sure).
    It is possible you have to put the closing of the second form in the OnTimer-trigger of the first. And use a boolean in the first form to say it's ontimer-trigger must close the second form.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.