Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Subreport with multilines based on main report Post Reply Post New Topic
Author Message
CrystalRiddle
Newbie
Newbie


Joined: 10 Apr 2018
Online Status: Offline
Posts: 4
Quote CrystalRiddle Replybullet Topic: Subreport with multilines based on main report
    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.


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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?
IP IP Logged
CrystalRiddle
Newbie
Newbie


Joined: 10 Apr 2018
Online Status: Offline
Posts: 4
Quote CrystalRiddle Replybullet 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.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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?
IP IP Logged
CrystalRiddle
Newbie
Newbie


Joined: 10 Apr 2018
Online Status: Offline
Posts: 4
Quote CrystalRiddle Replybullet 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.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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

Edited by DBlank - 20 Apr 2018 at 2:49am
IP IP Logged
CrystalRiddle
Newbie
Newbie


Joined: 10 Apr 2018
Online Status: Offline
Posts: 4
Quote CrystalRiddle Replybullet Posted: 20 Apr 2018 at 10:40pm
Thanks you again DBlank. It works.


IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.000 seconds.