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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value not carried over across the section. WHY???

Status
Not open for further replies.

request

Programmer
Dec 5, 2001
76
US
In my report header, I have formula called as EndDate

whileprintingrecords; dateVar maxdate;
maxdate := date(Maximum ({sp_outstanding_balance;1.setup_date}));
maxdate;

In my details, I have the formula cal_30_day as follows:
dateVar maxdate;
numberVar Num_of_days := maxdate - {sp_outstanding_balance;1.setup_date};
if Num_of_days < 31 then
{sp_outstanding_balance;1.balance}
else
0;

The problem is in details section, it is not catching the value of maxdate calculated in report header section. WHY???

Please help...



 
I'LL TELL YOU WHY. At the time the detail formula is being evaluated, the maxdate variable has not been set because the formula contains the max function and must be read while printing records. Add whileprintingrecords to the detail formula and this should work fine.
 
I cannot use whileprintingrecords in the detail formula.
The reason is I am creating a summary on this formula in my report. If I use whileprintingrecords in the detail formula, I can no longer summarize on this formula.

Please help. Thanks a ton.
 
What version of Crystal are you using? If you are using CR 9, you can use an SQL Command that will select from your SP and calculate the Max date on the server. Otherwise, you may be able to get the result from a subreport but that would be very convoluted and I would imagine will kill your performance.
 
Take the &quot;WhilePrintingRecords&quot; out of the formula in the report header

You should never have WhilePrintingRecords&quot; in any formula with a summary operation in it

Jim Broadbent
 
Do you have the group header repeated on every page? If so preceed the formula with the statement &quot;Not In RepeatedGroupHeader&quot;.



Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
I think that the problem is that you are using variables when variables are not needed. You could have done:

{@EndDate}:
date(Maximum ({sp_outstanding_balance;1.setup_date}))


{@cal_30_day}:
if {@EndDate} - {sp_outstanding_balance;1.setup_date} < 31
then {sp_outstanding_balance;1.balance}
else 0


You will need a variable in a separate running total formula if you try to create a total of the second formula.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
All:

Thanks for your suggestions.

Let me explain what I am doing in my report.

1. I have a stored procedure embedded in my report. The stored procedure returns 3 columns -> name, setup_date, balance.

2. In my report, I have done grouping by name.

3. The purpose of the report is to create a summary report where for each name , I have to calculate the total balance for each aging bucket. The aging bucket means 0-30 days, 31-60 days, 61-90 days and so on.

4. I have a formula @EndDate in my report header.
This is defined as

dateVar maxdate;
maxdate := date(Maximum ({sp_outstanding_balance;1.setup_date}));
maxdate;

5. My detail section is suppressed. However, in details section,for each aging bucket, I have the formula like :

@sum_30_day
dateVar maxdate;
numberVar Num_of_days := maxdate - {sp_outstanding_balance;1.setup_date};
if Num_of_days < 31 then
{sp_outstanding_balance;1.balance}
else
0;

@sum60day
dateVar maxdate;
numberVar Num_of_days := maxdate - {sp_outstanding_balance;1.setup_date};
if Num_of_days > 30 and Num_of_days < 61 then
{sp_outstanding_balance;1.balance}
else
0;

6. Then I right click on these formulas in detail section and do Insert->Summary, so that I can see the total balance under each bucket for each name in group footer section.

My problem is that the maxdate that has been calculated in @EndDate, the value does not get carried over in @sum_30_day , @sum_60_day.

kenhamady:
I had originally done what you have suggested. However, when I right click on the formulas @sum_30_day, @sum_60_Day, it does not show me Insert->Summary.

dgillz:
I am not sure I understand your suggestion. Can you please explain it further.

Please let me know what can I do to fix my problem. You all have been very helpful. Thanks a ton.






 
Your original problem is that you can't use Insert-Summary when you have formulas that use totals. Adding the variables won't solve the problem. Go back to your original formulas and use the 3-formula technique to do a running total of this column. see faq149-182 for how.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top