Close form out of subform

ngebhardngebhard Member Posts: 127
Hi together,

does anyone have an idea who to close a form out of a subform (i.e. sales order)? I only know about the "currform.close"-statement but this doesn't work out of the subform. Any hints?

Thanks a lot.
Best regards from Germany.
N. Gebhard
ProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt

Comments

  • FPulsfortFPulsfort Member Posts: 43
    The only way, i think, is to create a single-instance Codeunit with a global variable of the form. You start the form with a function in this Codeunit. Then you can close this form with another function which is called from the subform. This should work. Disadvantage: You have to start the form modaly!!!

    Hope this helps.

    Regards,
    Frank
  • pduckpduck Member Posts: 147
    the older solution uses a timer trigger in the mainform. when firing the timer trigger it looks into the subform and checks a variable if it should close or not.
  • ngebhardngebhard Member Posts: 127
    Hi together,

    I already tried to use a function in the main form. In the subform, I refer to this function. The function in the main form sais: currform.close! But I get the error message, that the form is not opened! Even if I run it modal. What's my mistake?

    Thanks a lot.
    Best regards,
    N. Gebhard
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
  • FPulsfortFPulsfort Member Posts: 43
    You can't use a function in the Mainform, because the Subform does not know, that it is a subform and so it doeas not know the mainform. If you declare a vairable of the main form in the subform and call a funtion, it is another instance of the mainform and not the one which is displayed.

    You can use the Ontimer trigger of the Mainform as pduck says, or you can use the way i told before.

    If you need more info, the post a repley.

    Regards,
    Frank
  • ngebhardngebhard Member Posts: 127
    Hi Frank,

    thanks a lot for your help, but I still don't get it. I have a codeunit with two simple functions. One to run the mainform modal. This works so far. :D

    Now, I wanted to create the second function which should close the form again. I wanted to call this function out of the subform. But I don't know how to define the function, that the form will be closed.

    Sorry, for asking again and again but it just doesn't work. :?

    Best regards,
    Nicole
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
  • FPulsfortFPulsfort Member Posts: 43
    First: Click in the Run-Function and look at the Properties. There is one called "SingleInstance". Set it to Yes. This is very important!
    Then you have to declare a global variable, say YourForm of Type Form and Subtype the Form, you want to run.
    After that make two functions
    1st with: YourForm.RUNMODAL; to start the form
    2nd with Yourform.CloseFormSubform; where CloseFromSubform is a function in your mainform, you have to create. In that you say: Currform.CLOSE;

    This should do the work.

    Regards,
    Frank
  • ngebhardngebhard Member Posts: 127
    Hi Frank,

    thanks a lot for your help! I forgot the property in the codeunit. Now it works as I wanted. I just get the message to clear the form on every second run, but this I will hopefully get by myself!!! :wink:

    Thank you very much!

    Best regards,
    Nicole
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
  • FPulsfortFPulsfort Member Posts: 43
    If you do not get it:
    Try it with CLEAR(YOurForm); before you call Yourform.RUNMODAL; :wink:

    Regards,
    Frank
  • manjusreemanjusree Member Posts: 79
    Hi,

    I have been browsing the forum for long on this topic. Purchase order form is my main form. PO authorization form (customized form) is opend from PO form. Again one more form is opened say PO edit form from PO authorization form. I am stuck at the closing of the two subforms!!...as these links tell, I have created single instance codeunit to open PO authorization form from Purchase order form modally. But I am confused where should I create close function. Is it in Purchase order form or in PO authorization form. I have tried both, but getting error message 'form is not open'...please help.

    Regards,
    Manju
Sign In or Register to comment.