Crystal Reports: How to pass parameter values between subreports? - crystal-reports

I've been working on a report that makes use of three subreports (A,B and C). The idea here is to locate the subreports side by side, where each one has its own list, but also this:
-A is located on the left (with columns c1, c2 and c3 where c1 is like customerID)
-B is located right after A and has columns (c1, c4 and c6) which should present data corresponding to the records of A according to the same value of c1 (customerID)
-C is located right after B, has the columns (c1, c7 and c8) and the same applies to it as in B.
I want it to look like one single table where c1 should only be visible once.
I also know there is the linking option but it doesn't seem to be working. If that's what you're gonna say, how can I configure the links? If not, how can I do this?
And no, there is no way this could be done in one single report.

To the extent I understand you want to pass the c1 value across 3 subreports. In this case link the subreports to main reports and pass the c1 value to the report selection formula of the sub reports so that all reports retrive only c1 value
Now in sub reports B and C .. don't keep C1 column just keep c1 column in sub report A.
But let me know any specific reason to use sub reports instead you can place coulms from c1 to 17 side by side in a main report

Related

How to change ordering on multiple columns in Crystal Reports

I am trying to display a list of names in crystal reports in multiple columns only if there are enough names that it would split into multiple pages otherwise. I want the ordering to be "across then down" when it's in two columns, otherwise if there aren't enough names, just display a single column of names in order.
The problem I'm having is that the ordering is off when it's in two columns, it goes like:
A - F
B - G
C
D
E
But I want it to be like:
A - B
C - D
E
F
G
And for only a small group that fits on one page, like this:
A
B
C
I have "Format with Multiple Columns" in the "Common" tab, and "Down and then Across" on the Layout tab.
Crystal doesn't have dynamic expression option for 'Printing direction' so you must commit to either 'Across then Down' or 'Down than Across'.
As a way around that, you can insert to subreports, each with a different choice for that property. Then, suppress one and show the other based on the number of records.

How ordering between sub reports

I have one report has two sub reports(A and B)
How to get B initializing after A,because B has a parameter is depended to A
Another hand how ordering between sub reports in jasper
Is it possible?my request is logical?
I suppose you can manage your order with a management on your report structure.
If possible:
You have a MAIN report
Under the MAIN report you can define a sub-report named A.
In the sub-report A you can define a sub-report B (so all B linked to your A will be exposed after the main A).
A simple example:
Main report: List of Italian football team of Lega Pro level (for example Taranto, Matera, Foggia and so on). This is your MAIN report.
For each team you have a list of football players.
To explode this list for each team, you have to define a sub-report named A.
For each player you want to show all matches where this player have taken apart.
You have to define a sub-report named B under A.
UPDATE
To manage this flow:
Main Information
A information (all rows)
B information (all rows)
The first part:
Definition of your data structure
You must have a main object with two listes.
A list for A information
A list for B information
The second part:
Definition of report structure
You must define two different subreport as follow:
In the main report you add two details band.
In the first detail band add a link to subreport A
In the second detail band add a link to subreport B
In this way. As first you process all A rows and the you'll process all B rows

Hold column group together in crosstab

I created a report in iReport with a crosstab containing 2 ColumnGroups.
If the crosstab contains more columns than fitting on the page, they are (correctly) continued on the next page. But how can I prevent JR from splitting inside a column group (so if the next column group doesn´t fit on the page, start it on the next page).
Example of colGroups i my crosstab:
Category 1 Category 2 Category 3
C1 C2 C3 C1 C2 C3 C1
Category 3
C2 C3
hope this will useful; inside jasper report on crosstab option there's a checkbox called "keeptogether"; this chekbox keep table on the same page without splitting it

iReport presenting data horizontally back

Using iReports, is there a way to display the data where it's going back and forth and pulling the data from one SQL statement?
Where an SQL query returned the following records
a0
a1
a2
a3
a4
a5
The report would be filled as follows ...
a0 a1
a2 a3
a4 a5
Normally I wouldn't have a problem doing a table, but I have to replicate someone's "application."
Yes, iReports allows you to fill your report so that the data is presented horizontally as you require in your question.
You can also specify how many columns you present in your report.
In the Report Inspector, right click on the report and select
Properties
In the Properties Dialog,
Click on the number beside Columns, enter 2.
Click on Print Order, select Horizontal
Click on Close
Press CTRL ALT PgDn to preview your report

Dynamic parameter not pulling list of values out of field

I have two kinds of parameters in a specific Crystal Report I am making -- two dates that I use directly in the SQL query, and a parameter that will filter the report based on sales reps within the query.
I defined the two dates (date1 and date2, if you will) when I created the command, and those work fine. However, when adding the dynamic parameter to choose which values I want for the 'sales rep' field, only a text box appears, meaning the parameter list hasn't been generated dynamically like advertised.
I know the reason for this -- the query hasn't run yet, so there aren't any dynamic values to pull. The date range is a necessary evil as well, since the report takes five minutes to run if a date range isn't set due to so many older records (which need to stick around do to history purposes).
Is it possible to generate this list dynamically at all, or am I stuck having to update a list with static values?
Thanks.
To get the dynamic parameter to work, you'll have to add whatever table to the report that contains the 'sales rep' field. You can pull the table in next to the SQL Command that you're creating, and just link them however you want with an outer join so as not to limit your records (You could even not link them at all, but Crystal will complain about having "Multiple starting points" or whatever.
Now you can pull the sales reps into the dynamic parameter and use it in either the SQL Command itself as a parameter, or you can just use it in the record selection formula to filter results from the SQL Command. In both cases, CR will query the database twice; the first time to simply get the entire list of reps and the second time to run the SQL Command.
The main takeaway here is that the table, not a command, needs to be in the report in order to be a candidate to populate dynamic parameters... even if you won't use that table again in the report. Hopefully that helps, even if it is 7 months late.
Finally figured this out:
Using SQL create the stored procedure that gathers your report data. This stored procedure CAN NOT have parameters. It must generate all your report data upon execution
Example 1: Exec MyReportStoredProcedure
Create another stored procedure to gather your parameter list values. Again no parameters used in the stored procedure.
Example 2: Exec MyCrystalParameterList
In Crystal Reports under Database -> Database Expert add both stored procedures (Called tables) to the "Selected Tables" section. Click "OK". Crystal will then try to make links between the two tables. Click "Remove All Links". Click "OK" on all link warnings that follow.
Now build your report using the columns from MyReportStoredProcedure
Run you report. You will NOT get prompts to enter parameters. All possible data will be displayed in the report.
* Now time to link the parameter to the data. *
Crystal reports will execute both stored procedures as soon as you open the report.
Crystal reports does not pull data based on the parameter like reporting services (SSRS).
Crystal filters the data based on the parameter value you selected after all data is gathered.
Running MyReportStoredProcedure returns the following:
1 Stop XX 7A [columns5] [columns6] [columns7] [columns8]
1 Gone CC 88 [columns5] [columns6] [columns7] [columns8]
1 Gone CC 88 [columns5] [columns6] [columns7] [columns8]
2 Nice XX C3 [columns5] [columns6] [columns7] [columns8]
3 Loop EE C3 [columns5] [columns6] [columns7] [columns8]
3 Loop DD C3 [columns5] [columns6] [columns7] [columns8]
3 Loop DD C3 [columns5] [columns6] [columns7] [columns8]
...
... 700,000,000 Additional records
...
Running MyCrystalParameterList returns the following:
1 Stop XX 7A
1 Gone CC 88
2 Nice XX C3
3 Loop EE C3
3 Loop DD C3
>> A distinct list of values only 5 rows <<
* Link the parameter data column to the corresponding report column *
Now link the parameter Column1 to the report column1. This link ties the main report values (MyReportStoredProcedure) to the parameter values (MyCrystalParameterList).
In Crystal Reports under Database -> Database Expert Click the tab called Links.
In this section you link the tables/columns together. You could have done this in the steps above but for better understanding I want you to do it here after showing the data returned for both stored procedures (tables).
* Create your cascading parameter *
In Crystal Reports find the Field Explorer panel. Usually its on the right side of the screen.
Now Right click [Parameter Fields] and select [New]
Name the parameter
leave the type as [String]
set "List of Values" to [Dynamic]
set "Choose a Data Source" radial button to [New]
In the table below the radial button, click in the first row under the word "Value"
A drop down showing both tables will be displayed ([MyReportStoredProcedure and MyCrystalParameterList])
Select the columns for your first parameter from your MyCrystalParameterList stored procedure (table).
Your column is now listed in the first row.
Now click the next row and select your next column from your parameter stored procedure (table).
repeat until all of your desired parameters are displayed in the table rows.
On the right side of this table you will see a column called "Parameters" there is text in this column for each row.
Click each field in the "Parameters" column and a parameter is created in Crystal report that corresponds to your parameter stored procedure (table) column.
Click "Okay" to close the "Create New Parameter" dialog box.
If you run your report, you will be prompted to select values for your parameters and the parameters will list available values.
ALL OF THE DATA WILL BE RETURNED IN THE REPORT!!! We are not done.
* Last step (Finally!) *
Tell Crystal reports to filter the report data based on the parameter value.
In crystal reports, click on Report -> Select Expert -> Record
A "Chose field" dialog box will display
Fields panel Look for the report stored procedure and expand it so the columns are showing
Select one of the columns that linked to the parameter stored procedure (table).
You will now see a formula dialog box with a default value of "is any value".
change this value to "is equal to"
A drop down box will appear to the right.
The drop down box will show your parameters!!!!!!
Select the parameter that corresponds to the report field you select.
repeat for all of your parameters.
Now run your report. The data is now filer by your parameter value!!
You are done!!!! Thank GOD!
Note:
You can make a single stored procedure for each parameter. Just add them to the report using Database Expert.
In my example I made one stored procedure that pulls all possible parameter combinations.
DO NOT ADJUST YOUR REGISTREY SETTING AND MAKE CRYSTAL REPORTS READ MORE THAN 1000 RECORDS!!!
Your report stored procedure can return 1 Billion records but your list of parameters should not be more than 1000 unique values.
You cannot build your parameter list from the report stored procedure because crystal reports will only look at the first 1000 records.
Your parameter list must be a separate stored procedure that pull distinct values.
* You have the foundation, Now build the rest. Good luck. *