terminate report from code
can anybody help me, how can i terminate the report from code (pascalscript) without showing the preview form?
i set Report.Terminated := True but preview form is always show...
thanks
i set Report.Terminated := True but preview form is always show...
thanks
Comments
assuming you loaded and called the report in this manner
frxreport1.loadfromfile('path&filename');
frxreport1.showreport;// this forms output and displays preview
the easiest is to include an frxdialog form in the report
with 2 buttons (run, cancel) and set their modal result properties to suit.
i want to print labels using "onmanualbuild" event in report. each label has particular count to print, but some of them have set unlimited count (999999). so when the count is unlimited, i want to show dialog form to specify new count for current label to print, or cancel (terminate) whole report by user without showing preview form.
sample of source code:
procedure PageOnManualBuild(Sender: TfrxComponent);
var
I, Count: Integer;
begin
if Engine.FinalPass then
begin
MasterData.Dataset.First;
while not MasterData.Dataset.Eof do
begin
Count := IIF(MasterData.DataSet.Value = NULL, 0, MasterData.DataSet.Value);
if Count = 999999 then
if UnlimitedFrm.ShowModal <> mrOk then
Engine.StopReport; //here i want not only stop report, but terminate it without showing preview form...
for I:= 1 to Count do
Engine.ShowBand(MasterData);
MasterData.Dataset.Next;
end;
end;
end;
i don't understand why you are insistent upon using the onmanual build
and a two passreport.
can you post a sample app in the binaries news group?
i posted a sample source code to binaries news group with topic "for gordk - terminate report from code"...
please have a look at it.
thank you in advance
here is what i would change based on what you posted
add a variable to the report's categorized variables named Cancelled
DO NOT give it any value.
change the report code
begin
//here i want to terminate whole report job...
set('Cancelled',true); //add this line
Report.Terminated := True;
end;
change your delphi code
procedure TForm2.Button1Click(Sender: TObject);
begin
frxReport1.PrepareReport;
if not frxreport1.variables= true then
frxReport1.ShowPreparedReport;
end;
BTW delphi form onshow event is a better place than oncreate to create client data
i would load report file in button click event and turn off store in dfm.
don't try it there is a bug
ill get back to you
i experimented with the code and i didn't figure out why you added a new variable "Canceled". is it possible to use native variable Terminated instead? See following code:
procedure TForm2.Button1Click(Sender: TObject);
begin
frxReport1.PrepareReport;
if not frxreport1.Terminated then
frxReport1.ShowPreparedReport;
end;
i tried the code above and it really works. where is the bug you mentioned?
thank you again
i think my head was out in deepspace last night.