Hi Guys,
I have built a new report and added controls to the Request form to take in some values to filter the data in the report.
I want to force the user to enter/select a value in each of the 2 controls I've added.
At the moment I have the following code in the OnPreReport trigger:
IF gRun = '' THEN BEGIN
ERROR('You must select a "Run/Transport No" value');
END;
This along with the other IF statement I have does the job, sort of. This closes the Request form.
Is there a way to stop processing the report, display a message to the user and redisplay the Request Form to the user..??? until they get it right or hit the Cancel button in frustration
Thanks
.
I'm not crazy !!! Just ask my toaster...
.
Comments
Test your fields there and until they give a value, you can exit(FALSE) (Never tried it though).
The other way is the way you are using.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
It didn't work unfortunately.. The report runs anyway with no criteria and then I get my Error messages at the end...
I'm not crazy !!! Just ask my toaster...
.
IF gRun = '' THEN BEGIN
message('You must select a "Run/Transport No" value');
CurrReport.QUIT;
REPORT.RUN(ID of the current Report);
END;
Technical Consultant, MS Dynamics NAV
This won't work - The RequestForm only closes once the report has finshed running, not when you click on the "Print"/"Preview" buttons.
I've done this by putting the textbox to enter that number on the options tab, so then you can program in OnAfterValidate of the request form. You can still program an ERROR, but it will put you back into the request form.
RIS Plus, LLC
I believe, Request form gets closed after the execution of OnPostReport trigger and hence after OnPreReport trigger too. :-k
Technical Consultant, MS Dynamics NAV
The Request form is closed before the OnPreReport trigger runs. It has to, because OnPreReport uses values that are entered into the request form.
The order of report triggers:
OnInitReport
enter values in Request form (dataitem tabs and options tab)
close request form (Click OK, print or print preview, cancel just closes it down)
OnPreReport
then it starts working through the dataitems
OnPostReport
RIS Plus, LLC
I did the following exercise.
a) Created a simple report with an option form (with a control on it) , one DataItem - Integer with MaxIteration = 1
b) Declared a global variable "i" of datatype integer in the report.
c) put a message with (after) incrementing "i" in some of the triggers as follows....
1)Integer - OnOpenForm()
i := i + 1;
MESSAGE( 'Integer - OnOpenForm() - %1',i);
2)Integer - OnCloseForm()
i := i + 1;
MESSAGE( 'Integer - OnCloseForm() - %1',i);
3)Report - OnPreReport()
i := i + 1;
MESSAGE( 'Report - OnPreReport() - %1',i);
4)Report - OnPostReport()
i := i + 1;
MESSAGE( 'Report - OnPostReport() - %1',i);
5)Integer - OnPreDataItem()
i := i + 1;
MESSAGE( 'Report - OnPreDataItem() - %1',i);
6)Integer - OnAfterGetRecord()
i := i + 1;
MESSAGE( 'Integer - OnAfterGetRecord() - %1',i);
When running the report I got the messages as .....
Integer - OnOpenForm() - 1
Report - OnPreReport() - 2
Integer - OnPreDataItem() - 3
Integer - OnAfterGetRecord() - 4
Report - OnPostReport() - 5
Integer - OncloseForm() - 6
So If there is nothing involved that I have ignored in my thought process, the above mentioned messages order is the order of their execution and implies that the option form only dissapears and is out of focus but is not closed before OnPostReport() trigger. :-k
Technical Consultant, MS Dynamics NAV