How to link nested reports in Crystal Reports?

I am using Crystal Reports 2008. I want to create a report in which I get a value from one SQL and this value field, which I must pass to another SQL, and get the result. Is it possible to do this?

+4
source share
2 answers

Firstly, I would recommend Jonathan Leffler to answer. It is much better if you can get the data formatted as you need using the query than trying to use a subreport located in the details or groups. Putting a report in the details section is essentially like starting a report for each record pulled by the main report.

Based on the above and the answer to your question, when you add a subtitle, you can right-click on the subtitle and select "Change Subreport Links". Here you can link the main data of the report with the data of the sub-report.

EDIT in response to your comment

1) There are two options that you can use here. You could create a parameter in a sub-report, add your logic to the Select Expert sub-heading so that it uses the new parameter, and then associate the column in the main report with the parameter in the sub-report using the Subreport Links screen.

2) Set up a common variable in the main report and in the subtitle, which can then be used in the Select Expert formula. For more information about this, see the next question. Recover Records in Crystal Reports

Hope this helps. Remember to move all the answers that would help and flag the correct answer to your questions if they are correct.

+4
source

Usually (but not always) you can combine two SQL statements in one - avoiding the complexity of sub-reports.

For an (simpler) example:

SELECT CustomerNum -- Returns number 919 FROM RecentOrder WHERE OrderNum = 23455; SELECT FirstName, LastName, EmailAddress FROM Customer WHERE CustomerNum = 919 

They can be combined in several ways:

 SELECT FirstName, LastName, EmailAddress FROM Customer WHERE CustomerNum = (SELECT CustomerNum FROM RecentOrder WHERE OrderNum = 23455 ) SELECT FirstName, LastName, EmailAddress FROM Customer AS C JOIN RecentOrder AS O ON C.CustomerNum = O.CustomerNum WHERE O.OrderNum = 23455 

Depending on your DBMS, you can also use the WITH clause up:

 WITH name1 AS ...query1...: SELECT ... FROM ...list including name1... WHERE ... 

It’s worth the effort to combine queries that make you think you need a sub-report. If you still need an extra report, you need more specialist help than I can offer.

+1
source

All Articles