"Form cannot be closed"-Error

aerisch
Member Posts: 9
Hi !
In a modal form (Form A), I try to start another modal form (Form
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 ?
In a modal form (Form A), I try to start another modal form (Form

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 ?
0
Comments
-
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.0 -
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 ...)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions