Closing a form

xrivoxrivo Member Posts: 56
Hi

We have a customer that ask for a form to be displayed in background always (users can't close it). I used OnQueryCloseForm trigger and it's ok, but the problem is when I try to close Navision, it won't close.

I've tried to close the form from function LoginEnd from codeunit 1 but doesn't work.

Thx for any help

Comments

  • Soft_TodSoft_Tod Member Posts: 43
    Hi xrivo.

    I guess you could do that. I don't know though how you start the form, important for my solution is that a global variable holds the form as long as the session is active.

    Form code:
    Form - OnQueryCloseForm() : Boolean
    EXIT(OK2Exit);
    
    FUNCTION DoExit()
    OK2Exit := TRUE; //Global variable in the form
    CLOSE;
    

    Codeunit:
    FUNCTION LoginStart()
    My4EverForm.RUN(); //Global variable for the Form
    
    FUNCTION LoginEnd()
    My4EverForm.DoExit();
    

    This is non-tested code, but I think my intentions are clear enough :wink:
    It is impossible to make anything foolproof, because fools are so ingenious.
  • xrivoxrivo Member Posts: 56
    I have tried this but doesn't work..because Navision try to run OnQueryCloseForm before LoginEnd.

    Thx
  • Soft_TodSoft_Tod Member Posts: 43
    Hi.

    Ok. I tested the solution I wrote, so I see what you mean. You can't tell the user to close the Main Menu before closing Navision I suppose (LoginStart and LoginEnd are called from there). frm as global variable fails too as Navision let go of the instance immediately.

    A solution could be:
    - A single instance Codeunit to hold the Status of the OK2Exit variable
    - User must close Main Menu before closing Navision.

    Not much of a help though :oops:

    (Would be nice with an exit type user/system in the Currform!)
    It is impossible to make anything foolproof, because fools are so ingenious.
  • aknakn Member Posts: 2
    Hi,

    try this in the OnQueryCloseForm-Trigger


    IF NOT CONFIRM(Text001) THEN
    EXIT(FALSE);

    So users will asked before close Form.
    If answered with "yes", the form will close and Navision can be closed too.

    Have fun
Sign In or Register to comment.