on 08-05-2022 9:32 PM
I have a Crystal Report with a sub report.
The sub report has the same where clause as the main report. but shows some additional data based upon system configuration. I went this way because I don't want to maintain two report files.based upon how a system is configured. I rather just show a sub report when necessary. (its DRY: Don't Repeat Yourself)
The where clause for the main report is built at at runtime based upon what inputs the user has given and the application uses the crystal report SDK to set the RecordSelectionFormula on the report document object.
I'd like to give the sub report this same where clause. The Report Selection Formula builder needs to see a boolean clause. Passing in the predefined RecordSelection in the from main report to the sub report won't work as I get the warning the "Record Selection Formula Editor needs to see a boolean. "
See how the application can set the RecordSelectionFormula on the main report, I suppose I can pass the where clause to the sub report but just curious, can the Crystal Report Record Selection Formula builder do the following
VIEWNAME.Field = {input}
if (input 2 = 1) then
AND VIEWNAME.FieldTwo > ("some text")
if (input3 = A) then
AND VIEWNAME.FieldThree > ( a number)
Suggestions
Best practice is to not use If statements in the selection formula. Crystal can't always pass them to the database where they're processed more efficiently and will instead bring all of the data into memory and filter it there.
I would re-write the selection formula like this:
VIEWNAME.Field = {input}
AND
(
input 2 <> 1
OR
VIEWNAME.FieldTwo > ("some text")
)
AND
(
input3 <> 'A'
OR
VIEWNAME.FieldThree > ( a number)
)
Secondly, I would create parameters in the report for input, input2, and input3. Use the parameters as the link from the main report to the matching parameters in the subreport. Then set the parameters in your code instead of building the RecordSelectionFormula. See here for information about how to set parameters in your code.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.