Jump to content
uniGUI Discussion Forums
Sign in to follow this  
TimPrior

Fastreport Refresh

Recommended Posts

Hi

I'm having a little problem using Fastreports in an UniGui application.

Firstly I filter the dataset using a unique code based on the pupil i want to print out. Then I export the Fastreport results as a PDF.

On the first networked computer I run the report for PupilA and I get a Pdf with PupilA information on it. On a second networked computer I run the report for PupilB but the resulting Pdf shows me PupilA s information instead of PupilB. (this only happens if I still have PupilA details still on the first computers screen).

Im not refreshing FastReports somewhere along the line.

My code is here

procedure TFmPrintOut.PrepareAndShow(Report: TfrxReport; Exp: TfrxPDFExport);
var
  AUrl : string;
begin

  Report.PrintOptions.ShowDialog := False;
  Report.ShowProgress := False;

  Report.EngineOptions.SilentMode := True;
  Report.EngineOptions.EnableThreadSafe := True;
  Report.EngineOptions.DestroyForms := False;
  Report.EngineOptions.UseGlobalDataSetList := False;

  Exp.Background := True;
  Exp.ShowProgress := true;
  Exp.ShowDialog := false;
  Exp.FileName := UniServerModule.NewCacheFileUrl(False, 'pdf', '', '', AUrl, True);
  Exp.DefaultPath := '';

  Report.PreviewOptions.AllowEdit := False;
  Report.PrepareReport;
  Report.Export(Exp);

  UniURLFrame1.URL := AUrl;
end;
 

 

procedure TFmPrintOut.UniFormBeforeShow(Sender: TObject);
var
  FRp : TfrxReport;
  FXp : TfrxPDFExport;

begin
 try

    FXp := TfrxPDFExport.Create(nil);
    try

      DmReports.QuPlcByPupil.filtered := false;
      DmReports.QuPlcByPupil.filter := '[PUPIL CODE] = '+quotedstr(DmPlcPupils.QuPupilListPupilCode.AsString);
      DmReports.QuPlcByPupil.filtered := true;
      FRp.LoadFromFile(UniServerModule.FilesFolderPath+'\reports\PupilPlcAll.fr3');
      PrepareAndShow(FRp, FXp);

    finally
      FRp.Free;
      FXp.Free;
    end;
  finally
  end;

end;
 

Any ideas on what Im doing wrong?

Thanks for all your help

 

Share this post


Link to post
Share on other sites

dmReport = datamodule for reports i think

Share this post


Link to post
Share on other sites

sorry here is my code again. for some reason i deleted the part where I created the report. Still have the same problem

 

procedure TFmPrintOut.PrepareAndShow(Report: TfrxReport; Exp: TfrxPDFExport);
var
  AUrl : string;
begin

  Report.PrintOptions.ShowDialog := False;
  Report.ShowProgress := False;

  Report.EngineOptions.SilentMode := True;
  Report.EngineOptions.EnableThreadSafe := True;
  Report.EngineOptions.DestroyForms := False;
  Report.EngineOptions.UseGlobalDataSetList := False;

  Exp.Background := True;
  Exp.ShowProgress := true;
  Exp.ShowDialog := false;
  Exp.FileName := UniServerModule.NewCacheFileUrl(False, 'pdf', '', '', AUrl, True);
  Exp.DefaultPath := '';

  Report.PreviewOptions.AllowEdit := False;
  Report.PrepareReport;
  Report.Export(Exp);

  UniURLFrame1.URL := AUrl;
end;
 

 

procedure TFmPrintOut.UniFormBeforeShow(Sender: TObject);
var
  FRp : TfrxReport;
  FXp : TfrxPDFExport;

begin
 try
    FRp := TfrxReport.Create(nil);
    FXp := TfrxPDFExport.Create(nil);
    try

      DmReports.QuPlcByPupil.filtered := false;
      DmReports.QuPlcByPupil.filter := '[PUPIL CODE] = '+quotedstr(DmPlcPupils.QuPupilListPupilCode.AsString);
      DmReports.QuPlcByPupil.filtered := true;
      FRp.LoadFromFile(UniServerModule.FilesFolderPath+'\reports\PupilPlcAll.fr3');
      PrepareAndShow(FRp, FXp);

    finally
      FRp.Free;
      FXp.Free;
    end;
  finally
  end;

end;

Share this post


Link to post
Share on other sites

Exp.ShowProgress := true;

if I'm not wrong, this is show VCL component, and this is problem in unigui. You have to set to False;

Share this post


Link to post
Share on other sites

Hi

no sorry Exp.Showprogress := false doesn't solve the problem. I have noticed that the sample freport thats included with UNIGUI suffers from the same problem. If you select Customer Information as a Report and ALFKI as a Report ID and let it create a PDF. When you run it on a second computer choose the same report but a different Report ID example WOLZA the pdf will display ALFKI.

 

Tim

Share this post


Link to post
Share on other sites

Hi

Ok I've solved it. Looks like the problem occurs when you create the Fastreport components dynamically. If you don't do that it seems to work fine.

Thanks for all you help and suggestions.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×