views:

3155

answers:

5

Using Crystal Reports I'm trying to display the running total of a database field in the header where all the labels are.

I've attempted to do this by placing the running total (RTversion) into a formula field with the following:

Shared stringvar CurrentVers; 
CurrentVers := {#CurrentVers};

and then in the page header section I have the following:

Shared stringvar CurrentVers; 
EvaluateAFter({#currentVers}); 
CurrentVers;

with {#CurrentVers} running the 1st largest number.

Is this incorrect?

Update: The goal is to display the latest version in the header near the labels to show what the current verseion is for comparison.

A: 

If {#CurrentVers} is a regular running total field, you should be able to place it in the page header directly rather than resort to an additional formula. I don't see the need for either formula field here, unless there's something unusual in the composition of {#CurrentVers} and a 'largest number' running total shouldn't require anything out of the ordinary.

CodeByMoonlight
Maybe I'm wrong on this, but I don't think just placing the running total in the header will work because of how the report reads top to bottom. This is off the top of my head so I could be wrong.
Dusty
They display, but obviously they only reflect the records processed up to that point. But the original question is far from clear on what they're trying to accomplish.
CodeByMoonlight
+2  A: 

Running-Total Fields, in my experience, only work in the footer sections.

You will need to create a manual running total.

Add a formula field to the Details section that populates a Global variable with whatever you are trying to capture. Something like:

//use WhileReadingRecords if the values can be gathered as the report pulls in values from the database.  Otherwise, use WhilePrintingRecords. 
WhileReadingRecords;
Global Stringvar CurrentVers;
//logic here to capture what you want
CurrentVers:=...

Add another formula field to the Header section. Add these two lines to it:

WhilePrintingRecords;
Global Stringvar CurrentVers;
Craig
+1 I believe this should work.
Dusty
How do you do a manual running total to screen for the maximum value of the currentversion? Do you use Maximum() function in the details section? I tried that much and it gave me an error saying it can't evaluate with WhileReadingRecords().
phill
I took out WhileReadingRecords, set the currentvers := ... and used the EvaluateAfter() function in the header and it worked.
phill
A: 

HELP!!

I have a asimilar problem...

But, my goal is to suppress a group header when the detailed runningcount=0. My runningcount is correct since it does not include suppressed records under the detailed section.

I'm using the following code right now and it's not working properly. ANy ideas why?? :)

UNDER GROUP HEADER (TEST1 field): ...................... Whileprintingrecords; Global booleanVar x := false;

UNDER DETAIL SECTION (TEST field): ...................... Whileprintingrecords; Global booleanVar x; if {@Display}<>0 then x := true else x := x

UNDER GROUP FOOTER (TEST2 field): .................... Whileprintingrecords; Global booleanVar x;

ANOTHER (DISPLAY) FIELD UNDER GROUP FOOTER: ................................ WhilePrintingRecords; Global NumberVar RunningCount; RunningCount;

Any help would be greatly appreciated. Thank you!!

Sarah
Sarah, as I commented on your question, this section is reserved for answers to the question and is not a forum. You should delete this before it gets downvoted.
Dusty
A: 

I figured it out..

I had to add a subreport to the main report. I copied the main report and renamed it as a subreport. In the subreport, I added a shared variable and then passed it to the main report. The trick is to place the subreport in the same group header, but a separate section above the section that needs to be suppressed. I actually added the following sections:

New section (same group-I placed subreport here; do not suppress) New Section (same group - I placed shared variable value here; do not suppress) Original Section (same group that has a header I need suppressed based on a running total)

Sarah
A: 

Just Create a formula like this

formula = Count ({Field to count},{GroupFieldName})

Just place it in group header section That's All.

Avneesh Sharma