Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting applied to first occurrence of subreport only

Status
Not open for further replies.

sdonaldson

Programmer
Jul 13, 2001
19
GB
Using CR v8.5.0.217 Developer Edition on Windows 2000.
I have a report which contains a two subreports, each called from the Detail section.
Each subreport displays a single numeric value using the following formula:

if isnull({NLhistory.year_no}) then
0
else
select {?CurrentPeriod}
case 1:
{NLhistory.month1}
case 2:
{NLhistory.month2}

(There are two subreports as I need to display the history from two different years on the same line of the report).
The only setting that I have changed on the Number tab of the Format Editor dialog is to uncheck "Allow Field Clipping".

When viewing the report, the first line (ie, the first execution of the subreport) shows zero (because there is no NLhistory record, so that's OK), but the subsequent lines of the report show blanks.
If I double click on the subreport on each line of the main report the value displayed in each case is "0.00".
It appears that CR is only executing the formula/applying the formatting to the first instance of the subreport only.
This problem only applies to the second of the two subreports - the first one shows "0.00" when there is no NLhistory record - but I cannot see any difference between the formula and formatting of the two subreports.

Any ideas as to what the problem is and how I resolve it ?

Thanks in advance,
Shaun
 
First thought is to troubleshoot by expanding what you display in the subreport. Show the values of {?CurrentPeriod} and {NLhistory.month1} thru {NLhistory.month12}. This will at least show what values your formula is dealing with and might highlight an unexpected problem.

Its usually a good idea to put these fields in their own detail section as you can supress them once they've served their purpose.
Steve Phillips, Crystal Consultant
 
how are the results of the subreports being displayed?

each subreport has its own detail section in the main report? or is the result being transfered back as a shared variable?

if isnull({NLhistory.year_no}) then
0
else
select {?CurrentPeriod}
case 1:
{NLhistory.month1}
case 2:
{NLhistory.month2}

also from what you are describing it appears the "Select" is not working properly

you might try this:

if isnull({NLhistory.year_no}) then
0
else
(
select {?CurrentPeriod}
case 1:
{NLhistory.month1}
case 2:
{NLhistory.month2}
);

I have had some flaky things happen with selects in nested formulas....you should also have a "default" as well to catch situations not satisfied by the select
{?CurrentPeriod} value... that is another source of a null return

try this version without a select

****************

if isnull({NLhistory.year_no}) then
0
else
(
if {?CurrentPeriod} = 1 then
{NLhistory.month1}
else if {?CurrentPeriod} = 2 then
{NLhistory.month2}
else
0;
);

****************

hope this helps

JimBroadbent@Hotmail.com

Reward good advice with a star, it reinforces us and helps others find answers to their problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top