Solved

Grouping in QuickReport

Posted on 1997-07-03
6
618 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now