Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Trouble adding subreport.

edited December 2003 in General
My client wants me to modify a report that provided information about a
package receipt. Orginally, the detail was the was simply that the packaged
arrived, vendor name, date, etc. and other unique information about the
package. Now they want and option for the package contents to be printed.

I created another query for the package contants, (1:N), ordered by the
packageID, added another pipeline as a detail pipeline and linked on the
packageID, built a group on pipeline2.packageID. I moved what was
previously the detail, into the group hearder and placed a subroutine into
the detail. The subroutine is populated with the package contents for each
package in the group header.

The sorting criteria for both queries is the same and have been tested
independent of each other and they retrieve the appropriate data.

All I get it the first package and it's contents. I have been trying to
resolve this for two days but to no end. I am following your example in the
tutorial for Master/Detail and have built several successfully in the past.

Any idea where I have gone astray.
Larry Killen

RB 5.54 ent., D-5

Comments

  • edited December 2003
    Hi Larry,

    Be sure each report (ie. the main report and subreport) is connected to the
    correct datapipeline using the Report | Data menu option. How are you
    linking your data? Check out the article below for more clues on what might
    be happening. If you still cannot solve the issue, please send an example
    in zip format to support@digital-metaphors.com.


    ------------------------------------------------------
    Tech Tip: Linking SQL Queries for Master/Detail Data
    ------------------------------------------------------

    The following example shows two options for linking SQL queries to create a
    master/detail relationship.

    In this example, we are using Delphi's DBDemos data to create a
    Customer/Order relationship. Thus we wish to link the Orders detail to the
    Customer master.

    I. Delphi Query Linking
    ------------------------

    a. Set the detail TQuery.DataSource property to point to the master
    query's TDataSource component.

    b. In the SQL "Where" clause for the detail query use a ':' followed by
    the linking field name from the master:

    example
    select *
    from orders
    where orders.CustNo = :CustNo

    Now each time the master record position changes, the detail query will
    automatically be refreshed with the correct result set.


    II. RB DataPipeline Linking
    -----------------------------

    a. Set the detail DataPipeline.MasterDataPipeline to point to the master
    DataPipeline.

    b. Use the detail DataPipeline.MasterFieldLinks property to define the
    linking relationship

    c. In the SQL for the detail, retrieve all records and sort them by the
    linking master field:

    select *
    from Orders
    order by CustNo


    Notes:

    1. Using RB DataPipeline, each query is executed only a single time - thus
    performance is much faster.

    2. RB Professional and Enterprise Editions include a visual Data environment
    for creating SQL queries, defining linking relationships, and creating
    Ask-At-Runtime parameters. Using the RB tools you could create the above
    linked queries in about 10 seconds.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2003
    Thanks Nico,
    And you were correct. I had to rework the query of the Master query (6
    level join) such that the PK was base table where all other tables were
    filtered against it.


This discussion has been closed.