Question

I am attempting to create a report using QuickReport in C++ Builder 6 and cannot produce the results I require.

I have attempted to create this report in two ways with marginal success. I've detailed one attempt below as it appears to be the most promising. I am new to QuickReport and have no idea where else to look for help. The documentation I've found online at http://www.quickreport.co.uk/ is minimal and does not adequately explain how to use the product beyond extremely simple reports.

The report should be formatted as such:

  • Manufacturer 1
    • A product
    • Another product
    • Yet another product
  • Manufacturer 2
    • My product
    • This product

Attempt 1: Two queries separating Manufacturer and Product data

  • Create a TQuery that gets a collection of Manufacturers by their IDs.
  • Create a Detail band.
  • Set the DataSet for the report to the Manufacturer TQuery.
  • Create Manufacturer Name QRDBText field on the Detail band associated with the Manufacturer TQuery and Manufacturer Name field.
  • Create a TQuery that gets a collection of Products by their Manufacturer's ID which is a parameter to the TQuery.
  • Create a Sub Detail band.
  • Set the DataSet for the Sub Detail band to the Product TQuery.
  • Create Product Name QRDBText field on the Sub Detail band associated with the Product TQuery and Product Name field.
  • Create events for the Sub Detail band:
    • BeforePrint:
      1. Takes the current Manufacturer ID and insert it as a parameter to the Product TQuery
      2. Activates the Product TQuery
    • AfterPrint:
      1. Deactivates the Product TQuery

Result: This almost gets me what I require. It displays every Manufacturer properly, however it only displays the first Product for each Manufacturer. I'm not sure if I'm incorrectly expecting the Sub Detail band to iterate through the results as the Detail band does, or if I'm missing some other necessary step to make it work. I've also considered using Loop or Child bands, but neither appear to offer the functionality I expect. Again, I can't seem to find decent documentation explaining QuickReport at all.

In the end, I can't determine if I'm expecting functionality QuickReport doesn't offer or if I'm thinking about this all wrong.

Was it helpful?

Solution

The solution:

  • Create a TQuery that gets a collection of Manufacturers by their IDs.
  • Create a Detail band.
  • Set the DataSet for the report to the Manufacturer TQuery.
  • Create Manufacturer Name QRDBText field on the Detail band associated with the Manufacturer TQuery and Manufacturer Name field.
  • Create a TQuery that gets a collection of Products by their Manufacturer's ID which is a parameter to the TQuery.
  • Create a Sub Detail band.
  • Set the DataSet for the Sub Detail band to the Product TQuery.
  • Create Product Name QRDBText field on the Sub Detail band associated with the Product TQuery and Product Name field.
  • NEW! Set the Detail band's LinkBand property to the Sub Detail band.
  • NEW! Prior to Printing/Previewing/etc. the report, in code set each query's Active property to True.
  • NEW! After Printing/Previewing/etc. the report, in code set each query's Active property to False.

The part that really threw me off was the "magic" that occurs wherein you needn't specify the parameters between the data source and the query for Products. It appears that if you specify a parameter required for a query pointing at a dataset then the query will look for a field sharing that name and match them.

I hope this helps someone down the road.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top