Options

"Form cannot be closed"-Error

aerischaerisch Member Posts: 9
Hi !

In a modal form (Form A), I try to start another modal form (Form B) for processing. If the process in Form B ends, it closes itself to return to Form A.

The code of Form A to open and run Form B is

CLEAR(frmFormB);

frmFormB.SetDocumentType(varDocumentType);
frmFormB.SetDocumentNo(varDocumentNo);

IF frmFormB.RUNMODAL = ACTION::OK THEN YIELD;

varItemNo := frmFormB.GetItemNo();

IF varItemNo <> '' THEN
CurrForm.CLOSE; // FormA.CLOSE !


When Form B is started and the code in the OnOpenForm()-Trigger is finished there is a system error message:

Form A connot be closed, because it is locked by Form B. Please finish Form B before closing.

What's the error ?

Comments

  • Options
    ArhontisArhontis Member Posts: 667
    Hi,

    Why don't you place the FormB.OnOpenForm code in your FormA and use a Dialog and Dialog.Update. That way you don't have to use another form and do the processing in your FormA. The use of dialogs with vars is intended for that purpose exactly.

    In your current situation, I tried to replicate the error, and placed on a button of FormA the code:
    CLEAR(FormB);
    IF FormB.RUNMODAL = ACTION::OK THEN YIELD;
    CurrForm.CLOSE;
    

    and in the FormB.OnOpenForm the code:
    CurrForm.Close;
    

    and all went well... FormA closes without any errors.
  • Options
    aerischaerisch Member Posts: 9
    Thank you,

    I found the mistake after I created new forms like you:

    The procedure described to open in FormA was written in the onPush-Trigger of a command button.

    ... and the property PushAction of this command button was set 'OK'

    Greetings from Germany (where the weather is bad and cold ...)
Sign In or Register to comment.