Re: - custom column headers
Tom Nesler <[email protected]> Wed, 24 Apr 2002 07:31:58 -0700 (PDT)
| Newsgroups | gmane.comp.lang.delphi.quick-reports |
|---|---|
| Message-ID | <[email protected]> |
--- Marty <[email protected]> wrote: > you can manually add data and information to the fields in any band > of the report itself. with out any additional controls. so as you > scroll through your result set you can assign the value to TQRLabels. > but you may want to collate your data before outputing to the report > in this method. > > At 02:23 PM 23/04/2002 -0500, you wrote: > >I'm new to the list, and since my usuals reports are very simple, > >I was happy with the help files, but that changed, I've been > > challenged with this problem: > > > >The report source is the RESULTS table: > > > >Fields: {place,test,result,...} > > place test result > >+---------+-------------+-------+ > >DOWNTOWN | AIR QUALITY | 0.3 | > >DOWNTOWN | WATER QUA | 10.5 | > >DOWNTOWN | V. COLERAE | N/A | > >ORANGE ST | AIR QUALITY | 0.3 | > >ORANGE ST | WATER QUA | 1.0 | > >ORANGE ST | V. COLERAE | N/A | > >B. PLAZA | AIR QUALITY | 0.4 | > >B. PLAZA | WATER QUA | 22.4 | > >B. PLAZA | V. COLERAE | 5.4 | > >... > >----------+-------------+-------+ > > > >and the report should looke something like this: > > > >+--------------------------------------------------------+ > > REPORT TITLE > >---------------------------------------------------------- > > > >Place | AIR QUALITY | WATER QUA | V. COLERA | ... > >----------------------------------------------------------- > >DOWNTOWN | 0.3 | 10.5 | N/A > >ORANGE ST | 0.3 | 1.0 | N/A > >B. PLAZA | 0.4 | 22.4 | 5.4 > >... > >------------------------------------------------------------ Fernando: Marty is correct about needing to organize your data so that all of the 'Place' records are grouped together. I thought I would flesh out Marty's suggestion so that you can see how it is done: 1. Create your report as usual with header bands and a detail band. Place the Table name in the QuickRep components Dataset. Create your column headers as normal. 2. Place QrLabels (not QrDBText components) where your data should reside in your detail band. In your case you need a label for the Place, Air quality, Water Quality, etc. 3. In the BeforePrint event place code like this: procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean); begin QRLblAirQual.Caption := ''; {Empty labels of Data before using} QRLblWaterQual.Caption := ''; QRLblVColera.Caption := ''; QrLblPlace.Caption := Table1Place.Value; QrLblAirQual.Caption := Table1Result.Value; Table1.Next; {increment table} QRLblWaterQual.Caption := Table1Result.Value; Table1.Next; {increment table} QRLblWaterVColera.Caption := FloatToStr(Table1Result.Value); end; Do not increment the table after the last label is filled. Let the Detail band's internal code handle the final increment. Notice: This code assumes that the table's data always comes in a specific order. If this is not true you will probably have to use a While loop and a case set to put the data into the labels correctly. Good Luck! ===== Tom Nesler Live Long...Code Well... and Prosper! V __________________________________________________ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/