Print Page | Close Window

Subreport with multilines based on main report

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22579
Printed Date: 29 Apr 2024 at 12:39am


Topic: Subreport with multilines based on main report
Posted By: CrystalRiddle
Subject: Subreport with multilines based on main report
Date Posted: 19 Apr 2018 at 7:29am
Good Day All,

Need help here.

Main report has data like

Product_Name, ITEMS
P_123, 2
P_124, 5
P_125, 1

Then I want to create a subreport for each product, subreport will display line(s) based on product items.
P_123>> subreport has two lines
P_124>> subreport has five lines
P_125>> subreport has 1 line only.

Not sure how to print multiple lines in subreport based on main report items.

Thanks for your help.





Replies:
Posted By: DBlank
Date Posted: 19 Apr 2018 at 8:11am
I think what you are asking for is a way to make the report print lines for someone to use pen and ink on not to actually pull in data, but you want the number of 'blank lines' to be a conditional, is that correct?

Do you know the max number of lines you might need?


Posted By: CrystalRiddle
Date Posted: 19 Apr 2018 at 8:31am
You are correct.   

I want to print lines for someone write data, but the lines are not from database tables. Lines are based on main report items value.   

I assume it will be less than 50 lines.

Thank you, DBlank.


Posted By: DBlank
Date Posted: 19 Apr 2018 at 8:45am
A simple approach is to not use a sub report but rather add in extra detail sections in the main report then conditionally suppress them based on the value you have for the number of lines. That is a bit off a pain for 50 detail sections.

In order to create the other options you would need to have a table that fetches the number of rows you want via a join which also means you need a access to adding a table or temp table or the like. Do you have rights for that sort of thing in the data source?


Posted By: CrystalRiddle
Date Posted: 19 Apr 2018 at 9:11am
Yes. I'm going to use row_number() function to generate row numbers from another small table which contains less than 120 rows.

The Main report data has to use tables links, cannot use command (SQL script).   

Thank you again DBlank.


Posted By: DBlank
Date Posted: 20 Apr 2018 at 2:48am
If you 'rows' table has a seeded integer column from 1 to 130 you and your other table has a value of ITEMS which is the number of rows you can join the two tables together but instead of using an = on the join use a <=
e.g.
select * from Products
JOIN NUmbersTable on NumbersTable.NumberField >= Products.ITEMS


Posted By: CrystalRiddle
Date Posted: 20 Apr 2018 at 10:40pm
Thanks you again DBlank. It works.





Print Page | Close Window