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

CR 7 : Variable behaviour at Header/Footer 1

Status
Not open for further replies.

ferdisig

Technical User
Feb 14, 2001
7
0
0
US
Hi all,

I'm kind new in CR .
I try to make sum calculation (I've tried with running total and 3 formula in header,detail,footer section) , and put the result at report header section within the same variable.
But the result at header section is Zero ,although the same varible is used at formula at report footer produce the correct value.
The strange thing if I edited the report in preview mode (like move the object in the report), then the formula at report header section would refresh and produce the correct value (the same as formula at report footer section as I expected). The problem is this report will be deployed at web so user cann't edit the report design, so the user will always get Zero Value at formula in the header section .
Any solution or explanation will be greatly appreciated.

BTW : The report produce 3 pages, expected formula is put at report header section and the calculated formula is put at report footer section.

TIA
Ferdi Sig
 
Variables are tricky, but you probably don't need them unless you need a running total. If you just need to print the sum a column of values (either grand total or subtotal) simply select the column you want to totals and use the menu options:

Insert - Grand Total

or

Insert - Subtotal


Variables are used often for running totals, but a running total would be zero at the beginning of the report. It would only be complete at the end. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Thanks for your response .
Yes, I need running total, I put this running total formula at report footer section , but I also need to show the result of this running total formula at report header section .
And you're right ,the problem is , at report header section the formula will produce Zero value (cause it hasn't calculated yet ) .
So how can I circumvent this problem ? so the formula at report header will produce the same/correct result as the running total formula would produce at report footer section.



TIA

Ferdi Sig
 
That depends on why you need a running total.

The nature of a running total is that it occurs while the report is printing. You can't refer to it before the report is complete.

Explain why you need a running total and I will see if there is anlternative approach. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Wow ,I really appreciate your quick response.
This is my running total formula :

Formula {@Reset} at group header
whileprintingrecords;
numbervar sum:=0;

Formula {@Calculate} at detail
whileprintingrecords;
numbervar sum;
numbervar array ArrayJournalNo;
if {SALFLDSAL.Journal_No} in ArrayJournalNo
then sum:=sum+{SALFLDSAL.Amount};

Formula {@CalcSum} at group footer
whileprintingrecords;
numbervar sum;
numbervar sumtotal:=sumtotal+sum;
sum;


Formula {@Result} at ReportFooter
whileprintingrecords;
numbervar sumtotal;

Formula {@Disp} at ReportHeader
numbervar sumtotal;

So I need to put the result from {@Result} also at Report Header with global variabel in formula {@Disp}, but formula {@Disp} will always produce Zero value , althoung formula {@Result} produce correct value.

Do you have any idea to workaround this problem

Thanks in advance

Ferdi Sig



 
I need to make sum from field {SALFLDGSAL.AMOUNT} ,but only for selected record under condition "if {SALFLDGSAL.Journal_No} in ArrayJournalNo " .
(BTW I also need grand total for all records in field {SALFLDGSAL.AMOUNT} under record selection). ArrayJournalNo is input by user .
The result from the sum(formula/running total) must be display at report header section.



Thanks in advance
Ferdi Sig
 
You don't need a running total. You need a conditional total. While you can use a running total to do a conditional total, there are better options. Especially since you need to see the total at the top of the report.

Create a simple formula called testAmt:

if {SALFLDSAL.Journal_No} in ArrayJournalNo
then {SALFLDSAL.Amount}
else 0


Now you can create a simple grand total or subtotal of testAmt as I described earlier. And now the grand total can go in the report header. No variables needed. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Thanks a lot for your tips and all your response.


Regards
Ferdi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top