lazreport and master detail lazarus / 16-Databases ---------------------------------------------------------------------- chrgra · 2009-02-11 21:17 Hello, I'am able to make a report in lazreport. But I can't create a suitable master detail report. Looking in the forum and internet, I can't find something useable about this. Does someone has a sample or a simple explanation? Maybe a link I could not find? Regards Chris Gradussen ---------------------------------------------------------------------- DougNettleton · 2009-02-13 22:05 Chris: If by "suitable" you mean forcing a page break on change of the master record, I can't help you - since I haven't figured that out yet.  But if you just want something like: Page Header master   detail   detail master   detail   detail   detail etc I did the following: 1) New Application: 2) Add ZConnection, ZQuery1, ZQuery2 - I use Firebird. 3) Add Datasource1, Datasource2 ZQuery1.SQL set to   select fld1, fld2, fld3 from dbfile1 order by fld1 ZQuery2.SQL set to    select fld1, fld2, fld3 from dbfile1 where fld1 = :fld1 ZQuery2.DataSource := DataSource1 4) Add DBGrid1, DBGrid2     - optional to see the relationship working. 5) Add frDBDataSet1, frDBDataSet2 frDataSet1.DataSet := ZQuery1 frDataSet2.DataSet := ZQuery2 6) Add frReport1, it didn't seem to matter which frDBDataSet I set the frReport1.DataSet to. 7) Add two buttons captions Design and Report with ... procedure TForm1.Button1Click(Sender: TObject); begin   frReport1.LoadFromFile('MasterDetail.lrf');   frReport1.DesignReport; end; procedure TForm1.Button2Click(Sender: TObject); begin   frReport1.LoadFromFile('MasterDetail.lrf');   frReport1.ShowReport; end; Right click on frReport1 choose Design Report a) Add Page header band with some rectangle objects for titles, run date, run time and page number information b) Add Master data band with some fields from ZQuery1 c) Add Detail data band with some fields from ZQuery2 d) save as 'MasterDetail.lrf' The only problem I had was under some conditions no details displayed and if the details band was narrower the rectangle objects I put on it, the band moved around independent of the rectangle objects. HTH, Doug ---------------------------------------------------------------------- chrgra · 2009-02-14 22:15 Thanks, I saw lazreport as a different tool. But at first you have to set the relationship with masterdetail in the lazarus designer! (By the way, I did not use a parameter, but master detail relationship in lazarus/zeosdbo). Testing page break: I just right click on the Master Data band and then I enable page break. So in my case every new department starts on a new page (the master data) Regards Chris ---------------------------------------------------------------------- slai · 2009-09-18 18:48 Hy I don't know if this thread is an actual question, but i solved this problem with a script. If you have 2 associated fields betwen master and detail then you can use this script on the detail data band. if [ZQueryDruck3."ID_PK"] = [ZQueryDruck4."ID_FK"] then     DetailData1.Visible := True else     DetailData1.Visible := False ID_PK = ID Primary Key ID_FK = ID Foreign Key