Stop form closing

Debbie140
Member Posts: 52
Is there a way to force a form to stay open if someone clicks the close button and a condition is not true. For example if I checked for a condition of the onClose trigger of the form can I then say if this is not true then keep the form open.
0
Comments
-
Hi Debbie
You can use the OnQueryCloseForm trigger.
Online HelpThe C/AL code in this trigger is executed immediately before the system closes the form.
[Ok]:= OnQueryCloseForm
Ok
Data type: boolean
This return value tells the system whether or not to close the form. The system checks the return value after each function call.
If Ok is... The system...
TRUE Closes the form (default)
FALSE Does not close the form
Applies to
Forms
Comments
If neither the form nor any child form returns FALSE in this trigger, the system calls the OnCloseForm trigger, first for all child forms and then for the form itself (the parent form).
If there is an error in the code in this trigger, the system cancels the close action but does not close the form.
You can write to the database from within this trigger.Answer the question and wait for the answer.0 -
Just put in the OnQueryCloseForm trigger:
IF NOT Condition THEN
ERROR('Make condition true');0 -
Hmm.
what must i do if i will that the Form doesn't closed.
in the Online Help are write that OnQueryCloseForm is executed before OnCloseForm. And that the Form doesn't Close if OnQueryCloseForm are FALSE.
I Have one Value what must be checked before Closed, if the check are ok then it is TRUE if is not ok thenn it is FALSE.
In the OnQueryCloseForm i try ti open an CONFRIM Dialog,
but what ever i click, the Form will close.
I Try with your ERROR() Dialog, but so i don't have any chance to close the Form ... :roll:
Thanks.Form - OnQueryCloseForm() : Boolean IF Dialog.CONFIRM('Are you sure?',TRUE) THEN Condition := TRUE ELSE Condition := FALSE; IF NOT Condition THEN ...
EDIT:
Sorry,...
I have it now...
in my FUnction what must check the value i was give a MESSAGE Out, now i have changed in ERROR Dialog, so no when i will close the form it says me that if a wrong value and after this it asked me if i would now close or not the form.(Oo)=*=(oO)0 -
Hi,
please try
Form - OnQueryCloseForm() : Boolean
exit(Dialog.CONFIRM('Are you sure?',TRUE));
br
Josef Metzbr
Josef Metz0 -
jm wrote:Hi,
please try
Form - OnQueryCloseForm() : Boolean
exit(Dialog.CONFIRM('Are you sure?',TRUE));
br
Josef Metz
Hmm. :?
I Have a textbox. In the Textbox Trigger OnValidate a execute a function that must check values, if i put in a value in the textbox, and then i go to close form or i press ESC, then the Forms Close, and after the Form was closed i get my Message that Something was do it. But why the Form is now Closed, it don't have affect.(Oo)=*=(oO)0 -
Hi,
please tell us a little bit more detailed what you want to do.
if i understood you right, then your code may look as follows:
OnOpenForm()
ValuesOk := FALSE;
OnCloseForm()
OnQueryCloseForm() : Boolean
exit(ValuesOk);
...
CheckValues(Input : Code[10]) : Boolean
if Input = 'X' then
exit(True)
else
exit(False);
and the Triggers of your Textbox:
OnAfterValidate()
ValuesOk := CheckValues(Input);
if not ValuesOk then
message('Value %1 is not ok',Input);
br
Josef Metzbr
Josef Metz0 -
jm wrote:Hi,
please tell us a little bit more detailed what you want to do.
if i understood you right, then your code may look as follows:
thats right, ...
in the TextBox Trigger OnValidate I execute my Validate function,...
thats okay if after change the value i activate another textbox or control,
but if i change the value without activate another control and i click directly on the closeForm (X) , then the Form will closed, and after it was closed i became the Message that something was do in the validate function.
I Think that i try execute my Function in another trigger and break with ERROR dialog if occurs something.
Other Method that i find nice but now i don't know how make it, is when i close the form that will not take changes to my record. I mean, that if i change the value in my textbox and then close the form that the function what i'm execute in the onvalidate trigger don't execute, the form close and nothing will be saved.
I try now change a little bit the function and try out it in other triggers.
Perhaps follow way is good...
When a record will load in the Form then :
myCheckedVars = TRUE
When then the validate function execute set
myCheckVars = FALSE if validate was false
and
myCheckVars = TRUE if validate was okay
and then when i will close the Form
ask for
myCheckVars
if is TRUE Close and if was wrong too close
hmm.(Oo)=*=(oO)0 -
How about in OnQueryCloseForm of the MainMenu
output text with information of server name and db one
(using Confirm(varTxt)).
So in order to find out of db just press 2 keys F12 -> ESC
from any form. (c)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