Open 2 forms, close 2 forms

jwilderjwilder Member Posts: 263
I am programatically opening first the Sales Comment Line Form like this:
SalesCommentLine.SETRANGE("Document Type",SalesCommentLine."Document Type"::Order);
SalesCommentLine.SETRANGE("No.","Document No.");
FORM.RUN(67,SalesCommentLine);
Then I am opening the Sales Order Form like this:
SalesHeader.GET(SalesHeader."Document Type"::Order,"Document No.");
FORM.RUNMODAL(42,SalesHeader);

So 2 forms open and if the windows aren't maximized they can be displayed next to each other. If the user closes the sales comment line form first, it pops them over to the Sales Order form which they can then close as well.

The problem is if they close the Sales Order Form first it keeps the Sales Comment Line Form open.

How can I close this form automatically? I want it to work as if I had used the RunFormLink property to open the Sales Comment Line Form. If you use that property and you close the main form it automatically knows to close the form in the RunFormLink property.

My guess is that this can't be done through code but maybe someone has an idea?

Comments

  • kinekine Member Posts: 12,562
    Is the SalesCommentLine local or global? If it is global, try to define it as local.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jwilderjwilder Member Posts: 263
    It is local already but becasue of your thought it made me notice that when I close the form that calls the code above (custom form called Find Order) it does close the Comment Line Form at that time. It's too bad it doesn't close it when the variable form goes out of scope.

    Any more thoughts?
  • kinekine Member Posts: 12,562
    Than try to call it from e.g. codeunit, which will go out of scope when the function ends (locally defined codeunit variable).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jwilderjwilder Member Posts: 263
    Tried it, didn't work.
Sign In or Register to comment.