Grouping in QuickReport

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
LVL 3
d4jaj1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

M_HoeperCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
d4jaj1Author Commented:
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
M_HoeperCommented:
No problem. I will send You the settings when I log into the Internet again from my own computer.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

M_HoeperCommented:
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
d4jaj1Author Commented:
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
d4jaj1Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.