Solved

Grouping in QuickReport

Posted on 1997-07-03
6
674 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month6 days, 3 hours left to enroll

627 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