Solved

Grouping in QuickReport

Posted on 1997-07-03
6
644 Views
Last Modified: 2013-11-22
I need to group records that have the same value (Relationship) in the same table using QuickReports.  This is very simple in any DB program, but I can't figure it out in Delphi.  Examples of  what I'd like to see is below,

FAMILY

Name      Home Fon          City
================================
John        404 555-1212    Atlanta
Carla        312 555-1212    Chicago

FRIEND

Name      Home Fon          City
================================
Steve       404 555-1212   St. Loius
Connie     312 555-1212    San Diego

ETC...

When I try to use either the Detail-Link or Group components, I doesn't GROUP them together, but displays what their relationship is for each record - like;

FRIEND

Name      Home Fon          City
================================
Steve       404 555-1212   St. Loius

FAMILY

Name      Home Fon          City
================================
John        404 555-1212    Atlanta

FAMILY

Name      Home Fon          City
================================
Carla        312 555-1212    Chicago
0
Comment
Question by:d4jaj1
  • 3
  • 3
6 Comments
 

Accepted Solution

by:
M_Hoeper earned 30 total points
ID: 1338150
I think the problem is that you have to preorder the Database entries. I took a TQuery and wrote the following lines into the SQL-property:

  select * from <table> order by <groupcol>

Then I took a TDatasource, a TQuickReport, a TQRGroup and three Bands: the Title, the GroupHeader and the Detail. The property DataField of TQRGroup is <groupcol>. And then it works.

Marc
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1338151
Sorry for the delay, but I have been trying to use the query example you mentioned but can't.  I have never used the tquery component and don't have the manuals anymore.  The problem I have is tying the query to the components.  When I try to set the DataField property to the Query, I don't get that option.

I hate to sound stupid, but I don't know how to use the query very well (at all really).
0
 

Expert Comment

by:M_Hoeper
ID: 1338152
No problem. I will send You the settings when I log into the Internet again from my own computer.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Expert Comment

by:M_Hoeper
ID: 1338153
Don't set the datasource-property in the TQuery-component.
You link the TDatabase to TQuere with the Dataset-Property in
the TDataset (not the Datasource-Property in the TQuery).

Description (Delphi-help)
Set the DataSource property to the name of a TDataSource component in the application to assign values to parameters not bound to values programmatically with Params or ParamByName. If the unbound parameter names match any column names in the specified data source, Delphi binds the current values of those fields to the corresponding parameters. This capability enables applications to have linked queries.

The following lines contain all the properties of my test-window. I marked the important lines.

object Form2: TForm2
  Left = 334
  Top = 135
  Width = 435
  Height = 300
  HorzScrollBar.Range = 1200
  VertScrollBar.Range = 2000
  AutoScroll = False
  Caption = 'Form2'
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object QRBand1: TQRBand
    Left = 0
    Top = 0
    Width = 1200
    Height = 41
    Align = alTop
    BandType = rbTitle                //!!
    Color = clWhite
    ForceNewPage = False
    Frame.Width = 0
    Ruler = qrrNone
    object QRLabel1: TQRLabel
      Left = 192
      Top = 16
      width = 20
      height = 13
      Caption = 'Title'
      AlignToBand = False
    end
  end
  object QRBand2: TQRBand
    Left = 0
    Top = 41
    Width = 1200
    Height = 41
    Align = alTop
    BandType = rbGroupHeader                  //!!
    Color = clWhite
    ForceNewPage = False
    Frame.Width = 0
    Ruler = qrrNone
    object QRDBText1: TQRDBText
      Left = 192
      Top = 16
      width = 65
      height = 17
      DataSource = DataSource1                //!!
      DataField = 'Kategorie'                 //!!
    end
  end
  object QRBand3: TQRBand
    Left = 0
    Top = 82
    Width = 1200
    Height = 23
    Align = alTop
    BandType = rbDetail
    Color = clWhite
    ForceNewPage = False
    Frame.Width = 0
    Ruler = qrrNone
    object QRDBText2: TQRDBText
      Left = 40
      Top = 0
      width = 65
      height = 17
      DataSource = DataSource1                      //!!
      DataField = 'Ausgabebezeichnung'              //!!
    end
  end
  object QuickReport1: TQuickReport
    DataSource = DataSource1                         //!!
    ColumnMarginInches = 0
    ColumnMarginMM = 0
    Columns = 1
    DisplayPrintDialog = False
    LeftMarginInches = 0
    LeftMarginMM = 0
    Orientation = poPortrait
    RestartData = True
    SQLCompatible = False
    TitleBeforeHeader = False
    Left = 72
    Top = 8
  end
  object Query1: TQuery
    Active = True
    DatabaseName = 'ParadoxBase'
    SQL.Strings = (
      'select * from Ausgaben.db order by Kategorie')
    Left = 8
    Top = 8
  end
  object DataSource1: TDataSource
    DataSet = Query1
    Left = 40
    Top = 8
  end
  object QRGroup1: TQRGroup
    DataSource = DataSource1               //!!
    DataField = 'Kategorie'                //!!
    HeaderBand = QRBand2                   //!!
    Level = 0
    Left = 104
    Top = 8
  end
end

Marc
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1338154
Marc, I'm really sorry for the delay, I've had too many problems with D2 and D3.  In any case, I finally got around to trying your suggestion and it works.  They all are grouped together by the field I mentioned.  There are two problems though.  I need this grouping in two types of reports - multi-column (like the labels report) and a simple list report.

First the Label Type report.  As I mentioned, the report is grouped correctly, however, the GroupBand is not on a line by itself.  Since QuickReport fills multi-column data vertically, not horizontally, once data reaches the bottom of the page - it re-starts on the same line level as the Group Header.  Example;

Ingredients           Milk     (Why does it put data this high?)
                             Bacon
Pickle                   Butter
Sugar
(and on...)

The problem with the simple list report is I can't seems to put column headers by the detail table, i.e. the column header appears at the top of the page - ABOVE the group header.  How do I group the data, then display the column header and the data below it. This is simple stuff with any database program.

I have increased the points for your wait time and my additional questions.

0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1338155
I assumed you didn't get the question, didn't have time to answer it or didn't know the answer.  Therefore, I graded you on your original answer.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question