Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Grouping in QuickReport

Posted on 1997-07-03
6
Medium Priority
?
703 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 120 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

886 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