Crystal Reports: How do I allow "set to null" when prompting for values to pass to subreports? - crystal-reports

I have created a report which links into subreports. I created parameter fields to feed into the parameters of the subreports using subreport links.
If I do not add a subreport link and therefore the subreport is prompting for the value directly it will allow the set to null option. However, if the enter value prompt is being generated from the parameter field I inserted then the set to null option is not displayed.
I have 12 subreports so I can't prompt for the same values 12 times.
I am using Crystal Reports XI designer and not .net

set up formulas with nothing in them (null values) to pass to the subreports

In XI, I've only seen the 'Set to Null' option when the report uses a stored procedure as its data source. Is this the case for your subreport?
Usually, subreports are linked to fields in the main report so that the user isn't prompted repeatedly (once for each time the section that contains the subreport is rendered). If they are linked, the only prompting that will be encountered it that of main report.
Crystal Reports XI parameter fields (created in the UI, not the result of a SP) do not have a 'Set to Null' option. As a result, each parameter will need to have some value.
You may want to have a look at my Crystal Reports: Optional-Multi-Select Parameters posting on how you can add some optional values to your parameters.

Related

Crystal Reports - Subreport with stored procedure as datasource creates a new param and doesn't pass it to the stored proc

Using Crystal Reports XI, I have a main report. In this report, I have a Formula Field named XXXCompanyFilter. This is set programmatically at run time and I want to pass it to a subreport.
I add a subreport that has a stored procedure as an input parameter. The parameter is named #co.
A Parameter Field is automatically created in my subreport called #co.
I return to my main report and right-click the subreport and choose Change Subreport Links. I choose the Formula Field XXXCompanyFilter from the Available Fields list and move it to the Field(s) to link to: list.
At this point I expect to be able to choose the subreport's #co parameter in the Subreport parameter field to use: drop down, but it is not there. I have unchecked the Select data in subreport based on field: checkbox.
I've tried selecting the ?Pm-#XXXCompanyFilter option, and that (I think) causes a new subreport parameter to be created:
After that, I do get the new subreport parameter to show in the drop down:
However, this new parameter doesn't seem to do anything, and I'm still prompted to enter the #co subreport parameter whenever I run the report. If I enter a value for the #co parameter the report returns the data I expect.
I've created several subreports to see if the behavior changes. I've tried it with the subreport wizard and with subreports I've created normally. I always get a 2nd, non-useful subreport parameter and the #co parameter is never set, so I am prompted for it.
I feel like if I could select the #co parameter in the drop down list it would work as needed.
I've checked out multiple SO posts, and I've googled the issue but everything I find says I'm doing it right. What am I doing wrong, or what do I need to do to make the #co parameter available in the drop down?
I solved this by specifying a database field in the Available Fields list when creating the subreport link and following the instructions in my original post.
Apparently it just won't work if you specify a Formula Field in the Available Fields list. I can't find any documentation on this but that's the conclusion I come to after reaching a solution by trial and error.

Crystal Reports: Setting subreport parameters with one main report parameter [duplicate]

How can we pass a parameter from the main report to a subreport in Crystal Reports XI? I have a parameter in the main report. Now, I want to pass the same parameter to subreports. Please help me.
Right-click on the subreport object and choose Change SubReport Links, then select how the parameter is to be used by the subreport.
Using CodebyMoonlight's solution requires a relation between main report and subreport.
If there is no relation between both of them, you can use Shared Variables to pass values between both of them, as shared variable can be set and displayed anywhere in main report or sub report.
Shared NumberVar x := 5;
Perform following easy steps:
Create New Parameter lets say "StartDate" in Parameter Fields in Field Explorer in Crystal Report
Create New Parameter lets say "StartDateSubReport" in Parameter Fields in Field Explorer in your Subreport
Now in Main report file, Right Click Subreport lets say "EmployeesList.rpt" and click Change Subreport Links menu
Select "StartDate" from Available Fields from Available Fields Tab and click on ">" button to make it vailable to link in subreport
Now bind your "StartDate" which you have made available by selecting it with "StartDateSubReport" in dropdown available in "Subreport Parameter Field to use"
parameter sharing between main report and sub report "Right-click on the subreport object and choose Change SubReport Links, then select how the parameter is to be used by the subreport." works for me
I had the same problem. The main report loaded first and then the subreport. You have to load the subreport before you can use the variable.
I think that using
Right Click and Sub-report Links
or
Shared Var Between Report and Sub-report
Both using Selection formula so it is suitable for limited data only
Selection formula working after loading all records from Database table ... report loading bad performance
so i'm tring to limit rows by passing some parameter from C#/VB and send others from main to sub report
For example if you need the transaction of items in period and you can pass the period parameter from application (c# ..) and using Sub-report Links to send itemID
https://kb.blackbaud.com/articles/Article/52328
Create a parameter field in the main report.
From the main report, right click on the subreport, and select Change Subreport Links.
In the subreport linking window, select the parameter field from the window labeled "Available Fields", and click on the ">" button to move it to the window on the right labeled "Fields to link to"
Below, make sure you have a check next to Select data in subreport based on field.
Below the checkbox, if it is not already there, select the field from the subreport, to which you would like the parameter field linked.
Click OK

Crystal Subreport Common Headers

Maybe someone can Help me find the right technique.
I have a number of Crystal Reports that I am updating (Crystal Reports XI).
These reports each have an SQL Function associated with each that either retrieves records from the database (if any meet criteria) or returns an Empty Dataset (which happens daily).
These are executed in a batch process and directs the output to a PDF file which is emailed to users.
I am relatively new to Crystal Reports.
I am attempting to use a common SubReport to format/gather data for the Headers/Footers used in these documents. So far - most of this is working as I would expect. This allows me to use a single SubReport to generate the same Header/Footer in multiple reports (at least that's my goal).
However - I added a Report Footer section to the Main Report - my plan with this was to generate a Report Footer that would contain the following information:
A static Text Message that reads " --- END OF DOCUMENT ---"
The Report Title of the "Main Report"
The Date and Time that the Document was generated and Total Number of pages.
Sounds pretty simple.
So SubReport is named: "END-OF-DOCUMENT-SUBREPORT"
I used the "Special Fields" Data Date, Data Time, & Page N of M
Since the "Special Field" Report Title is returning me the "END-OF-DOCUMENT-SUBREPORT" value I used a Parameter field to pass the Report Title value from the Main Report to the SubReport.
This all works fine - HOWEVER - with the addition of the Linked Parameter Field from the Main to the SubReport - when I execute the report to generate the document - the SubReport ends up showing a blank Report Footer - that I can click on to reveal the "END-OF-DOCUMENT-SUBREPORT" in another Tab.
Without the Parameter field - it didn't do this and the information from the SubReport appeared on the last page of the document.
Is this a standard behavior of Crystal?
I'm not sure how to Suppress the "Drill Down" feature and still display the Report Section.
You can pass variable between you Main Report and sub Report. You can also create variable and assigned them to a sub report. As aMazing mention, creating Header and Report Footer sub report is not common. It is even messy. If you want something generic, I will create a report template that you will use in the future.
Have a good day!

My parameters on my main report won't add to my subreport in crystal reports

I have done this before, where the main report's parameters are passed on to the subreport. Currently, there are 2 parameters from the main report being passed to my subreport, but I need to add 2 more. When I go through the "Change Subreport Links" option and select and add the needed parameters, it simply doesn't save. I am not sure how else to add these.
Steps:
create desired parameters in sub-report
create corresponding parameters in main report
link with 'linking expert'
The datatypes of the parameters fields did not match, so the two were not correlating.

Crystal Reports - One report that lets user select from multiple reports

I need to "merge" 3 big reports.
Is it possible to just create a drop down menu that lets the user select which report to view?
Then just put all 3 reports into one as sub-reports?
Thanks
You could:
create a dummy main report
embed each of the 3 reports as a sub-report
create a pick-list parameter that allows a person to select one of the reports to be shown
suppress sub-reports that aren't in the parameter's chosen value
** edit **
In addition, create the necessary parameter fields in the main report, then link them to the corresponding parameter fields in each sub-report. This will eliminate the report from prompting repeated for each parameter.