Passing result of a query as parameter in Crystal Report - crystal-reports

I am new to crystal report, I have a report to generate which contains two queries.
I need to run the first query which returns a single column.
I need to fetch the result of the first query one by one and pass it as a parameter to the second query. And finally running the second query.
It would be helpful if anyone tell me the steps about how to do this.
I am using crystal report 2008, I hope the above mentioned information is sufficient, if not please let me know.

you need to use sub reports for this purpose...
Take query 1 in main repoirt and query 2 in sub report. Place the sub report in the section that is coming after the data in main report.
Then pass the filed of mail report to sub report using the sub report links and then apply condition on this field in sub report Record Selection Formula

Related

I Want to Print 1 report in two copies(2 Prints ) with same data in crystal report having Subreport?

Normally if we have report without any sub report in it, it is easy to print twice the report by adding same report in page footer as sub report . But if report contains already subreport than it is not possible to again add subreport in it. So how can we Print such report twice in crystal report.
It must exist a better solution, but here it goes two workarounds:
Alternative 1:
Turn your main report into a subreport (with its child subreport) and duplicate it in a brand new main report.
Advice: subreports use to perform poorly, but if your data is not large, it is ok.
Alternative 2:
If you can easily manipulate the data source (for example, if your generating a dataset through code), use the details section for your report, insert an extra table in your data source where the number of lines is the number of "copies" that you want to print. Let your main table join with this "fake" table without links. The result will be a cartesian product, so you will get the number of copies you want.
Extra note: Crystal let you use another rpt file as a subreport. Maybe you can use this feature to solve your problem. Personally, I don't like this feature, because it does not behave like I would expect by intuition.

Pass parameters from main report to sub reports

I have searched many sites for this but the suggestions do not work. I set 2 parameters on the main report. I have added the 2 sub reports, both are to use the same values of these parameters. The 2 parameters are date values I need to use as a date range in the select expert where I am using a Is Between check. I right click on the sub report and click the Change the sub report links. When I select the parameter in the Available Fields: drop down the Select data in subreport based on field: is not populated with any choices - which was one of the suggestions I read about. Can someone walk me thru this process?
Thanks
You have to create parameters in your Sub reports first for them to appear in the Connecting list and then map to main reports parameters

Trying to remove exisitng parameters in Crystal Report 10 report by creating new subreport to provide the parameter data

Hello: I am trying to run crystal report 10 report from command line (and I'm new to crystal). The report has two date parameters ?from and ?to. I can query a different database to get the ?from and ?to parameters. So what I'm trying to do is get rid of the external parameters by generating the dates from within the report to replace/populate ?from and ?to.
Can I somehow add a sub-report to query Oracle to get the ?to and ?from dates? This new sub-report would need to run first since the other four reports (3 subs and 1 main report hitting SQL server) all use these date parameters?
Thanks for any help.
To the extent I know, Whether you use sub report of main report if a user needs to enter his own parameters to query the database then you need to create external parameters
Edit------------------------------------------------------------------------------------------------
Since you are trying to get the date input from different database... your approach is correct to create a sub report for this.
Make sure to place the sub report first in order from where you are taking the values.
Either use a shared variable or through parameter linking get the date values to main report and pass the values to remaining sub reports through linking option in sub report links.

Multiple Crystal Report to be printed on same report

I have a crystal report that takes only about 1/3rd of the report space.
I have field read from the database which is an integer value.
I wish to print this report number of times as read from the database on the same page.
Any idea on how this can be achieved?
I can only use crystal report for achieving this.
Thanks in advance.
You can create another report and add your current report as a subreport multiple times
Lan is correct, build another report and add your current report as a subreport.
Here's the trick:
On your main report, have it make a list of all of the items that
you'd like to run the sub-report on.
On your sub-report, add a parameter called "itemNumber" or something like that. Then change your Subreport Links so the new "itemNumber" parameter is linked to the item on your top level report.
Now hide the field on the main report but leave the
subreport visible.!
This should make your report run for all items at one time.
In this case you can create a table with the maximum number of prints you will ever use. For example if you think you might need to print the report 100 times your table should contain records from 1 to 100. So lets assume this is the case- create a table , name it Copies and add a field CopyNo. Create a 100 records and set CopyNo from 1 to 100. Create the a main report based on Copies table - the record selection formula will be something like :
Copies.CopyNo<=#NumberOfCopies
#NumberOfCopies is a parameter , which you can set in order to control the printed copies. Create your actual report as a subreport and place it in the details section of the main report. When you run the report it will ask you for the number of copies and when you insert it, will print the same subreport as many times as the number you provide.

crystal report, subreport details section not displaying the next batch of records

I put a subreport in the footer of my main report and I set its details section to display five records per page (through the paging tab).
I am sure my query returns nine records.
Upon previewing the report, on the first page, it displays the first five records.
However, on the second page, it also displays the first five records not the remaining four records.
I am not sure where is the problem since I just started using crystal reports. Hope you can help me. Thanks.
You need to set your sub report links.
This will link the data from your main report to your sub report. In Crystal 2008 you right click on the sub report and choose 'Change Sub report links...' option. Then you can select the data to flow from the main report to your sub report. Otherwise your sub report is being viewed as a completely separate report that you are just inserting on top of your main report and it will be the same at every instance.
Also, it might be a good idea to use groups instead of the details section when inserting sub reports.