Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Parameter passing from main to sub reports Post Reply Post New Topic
Page  of 2 Next >>
Author Message
sa-user
Groupie
Groupie


Joined: 29 Jun 2011
Online Status: Offline
Posts: 65
Quote sa-user Replybullet Topic: Parameter passing from main to sub reports
    Posted: 07 Jul 2011 at 4:21pm
I have a requirement as below example. what is the best way to achiev it? Thanks
An example or any resource for this would help
 
 
Main Report

Product
abc
def
pqr

above products should be links and when clicked on any it should give that product specific data
ex: when clicked on abc sub report opens up for abc. [similarly when clicked on def or pqr sub reports with its detail should open up]

Sub report

Product  = abc
unit = 30
dosage form = oral
 
 
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 08 Jul 2011 at 3:37am
do you want an on demand sub report or do you just want a list of products and associated data?
sharona
IP IP Logged
sa-user
Groupie
Groupie


Joined: 29 Jun 2011
Online Status: Offline
Posts: 65
Quote sa-user Replybullet Posted: 08 Jul 2011 at 4:32am

on demand sub report

 
Thanks


Edited by sa-user - 08 Jul 2011 at 4:40am
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 08 Jul 2011 at 5:03am
I would create a group by product id in the main report
place your sub report in the group
join the sub to the main by the product id.
sharona
IP IP Logged
sa-user
Groupie
Groupie


Joined: 29 Jun 2011
Online Status: Offline
Posts: 65
Quote sa-user Replybullet Posted: 08 Jul 2011 at 5:06am
Thanks for the reply...
I was looking for some step by step process if any.
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 08 Jul 2011 at 5:51am

SUBREPORTS

 

Subreports are an advanced feature that can solve some complex database reporting problems. These include:

  • Data for the report are coming from more than one data source
  • Table joins cannot be used to retrieve the required records
  • Several views of the same data are required

If you have these problems, display some of the report as a main report and the remainder in one or more subreports.

Then you have an important design decision to make. Which part of the report do you do in the main report, and which parts do you want in subreports?

The main report must do the primary record selection and grouping. You cannot group or select data based on values in the subreport. The subreport is then used complete the missing values–essentially "fill in the blanks."

One extension to this approach is to use a subreport to retrieve a value, and then use conditional formatting in the main report that uses the subreport information. But there are limitations to this:

  • The subreport has to take up some vertical space in the report.
  • Subreports in suppressed sections do not get processed, so any shared variables expect from them will not be calculated.

The solution is to create the parameter in the subreport prior to creating the link. When you create a link to an existing parameter in the subreport, it is saved when you exit the subreport link form.

1.        Select INSERT

2.        SUBREPORT

3.        The subreport wizard appears.

4.        Name the subreport.

5.        Select REPORT WIZARD

6.        Create New Database Connection

7.        The database expert displays

8.        Select CREATE NEW CONNECTION by clicking the node to the left.

9.        The screen displays the database and the TABLES, VIEWS and STORED PROCEDURES

10.     Select the tables and move them to the select table’s area.

11.     If a stored procedure or view is being used, and they contain PARAMETERS built into the stored procedure or view, you will be prompted to enter value(s).

12.     Select NEXT

13.     The LINK screen displays. 

14.     Select NEXT

15.     The field selection screen displays

16.     Select the fields and drag them to the detail section of the report.

17.     Once a field has been used in the report it is designated with a green check to the left of the field name in the field explorer.To view the data that is displayed select the REFRESH DATA icon.

18.     Select FINISH

19.     The screen reverts back to the main screen.

20.     Place the sub report in the location where it should display.

21.     Right click on the sub report

22.     Select EDIT

23.     Format the subreport to your desired layout.

24.     Dependent on the purpose of the subreport, you may need to do one or all of the following;

 

a.        Create Several views of the same data are required where you would layout the subreport identical to the main report. (if you want to see costs in one area of the report and fees in another)

b.        Create a subreport to retrieve values to use in the main report.

Linking the Subreports

Link a field or formula from the main report to a field or formula in the subreport to retrieve records based on that link. The field must be in both reports to link the subreport to the main report.

25.     Right click on the subreport

26.     Select CHANGE SUBREPORT LINKS

27.     The following screen displays

28.     Select a field from the main report which is located under AVAILABLE FIELDS.

29.     Move it to the FIELDS TO LINK TO.

30.     If the field is available in the subreport to join to it will display in SELECT DATA IN SUBREPORT BASED ON FIELD.

sharona
IP IP Logged
sa-user
Groupie
Groupie


Joined: 29 Jun 2011
Online Status: Offline
Posts: 65
Quote sa-user Replybullet Posted: 08 Jul 2011 at 6:29am
Thank you much for the steps. It worked.
I used the on demand option.
 
One last question:
In the main report when i retreive data, can i make this data as a link to the sub report? With the current solution there will be an additional link in the main report.
 
 
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 11 Jul 2011 at 2:40am
in other words you want a result from a field to be your link
such as
Product  = abc????
 
or do you want the sub report to display the associated data from the main report? so if you want to see the results of a product, you need to group the main report by product id, place your sub in the group and link by product id, make sure your sub report is grouped the same way.
sharona
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 11 Jul 2011 at 5:04am
I think you want this...
in the main report
right click on the subreport and select Format Subreport
select the Subreport tab
select the fomrula (x-2) button for 'On demand subreport caption'
add the prodyuct name feild as the formula
table.product
save and close it.
now instead of the field repeating 'sub report'  each row should have the different names of the products.
IP IP Logged
sa-user
Groupie
Groupie


Joined: 29 Jun 2011
Online Status: Offline
Posts: 65
Quote sa-user Replybullet Posted: 11 Jul 2011 at 5:20am
Thanks a lot.
This is exactly what i needed.
IP IP Logged
Page  of 2 Next >>
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.031 seconds.