TimPrior Posted January 14, 2019 Share Posted January 14, 2019 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 Quote Link to comment Share on other sites More sharing options...
Jean-Marc Kiener Posted January 14, 2019 Share Posted January 14, 2019 FRp is not created? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted January 14, 2019 Administrators Share Posted January 14, 2019 Hi, What's dmreports? It isn't clear from your code. Quote Link to comment Share on other sites More sharing options...
mierlp Posted January 14, 2019 Share Posted January 14, 2019 dmReport = datamodule for reports i think Quote Link to comment Share on other sites More sharing options...
TimPrior Posted January 15, 2019 Author Share Posted January 15, 2019 Hi Thanks for the replies yes dmreport is my datamodule Quote Link to comment Share on other sites More sharing options...
TimPrior Posted January 15, 2019 Author Share Posted January 15, 2019 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; Quote Link to comment Share on other sites More sharing options...
Freeman35 Posted January 15, 2019 Share Posted January 15, 2019 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; Quote Link to comment Share on other sites More sharing options...
TimPrior Posted January 15, 2019 Author Share Posted January 15, 2019 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 Quote Link to comment Share on other sites More sharing options...
TimPrior Posted January 16, 2019 Author Share Posted January 16, 2019 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.