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

Help with getting proper global var value

Status
Not open for further replies.

TomBoardman

Programmer
Aug 25, 2006
26
US
I have several groups with a title "A", "B",etc up to about "H". In the groupfooter I have a summary field for the numeric field in each group. In the report header I have columns titled "A", "B" up to "H". Under each column heading I want to print the group total in the corresponding groupfooter. I have a formula field in the group footer that uses a Select Case statement. For example
Global VarA as number
Global VarB as number
Select case Groupname
case "A"
VarA=Sum of group
case "B"
VarB=Sum of group

so on

I then have a formula field in the rep header

Global VarA as number
formula=VarA

But my VarA is 0. I've tried using the WhilePrintingRecords but no success. Where am I screwed up?

Tom
 
Your better served topost technical information rather than descriptions.

Crystal version
Database/connectivity
Example data
Expected output

Global variables are used to pass values between main and subreports, not for within a single report.

Instead of using groups, Insert a crosstab into the report header or the report footer, then place the A,B...H field as the Column, and the value asthe summary value.

-k
 
Please post your exact formulas for A, and you should have 3 - one to initiale the variable in the group header, one to accumulate it in the details section, and one to display it in the group footer.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"A fine is a tax for doing wrong. A tax is a fine for doing well.
" - unknown
 
I explored using a crosstab but found that in order to as you said ," then place the A,B...H field as the Column, and the value as the summary value." all of my columns types for my summary table needed to exist in the current data- which do not. So I am falling back to my use of a var total. Also I understood that global vars can't be passed to subreports and that global is the scope to use within the same report. I'm I off on that? Thanks synapsevampire.

dgillz, The exact forumla for A is
Global RunA as number
formula=RunA

I have this formula in the page header; not group though.

I then have a formula in the details section

Global RunA as number
Global RunB as number...so on to RunH
Select Case Groupname
Case "A"
RunA=RunA+{Fieldval}
Case "B"
RunB=RunB+{Fieldval}
so on
end select

Then I have the same formula field in my page footer as in the header. I keep getting 0. I've tried moving the field into other sections but nothing. My understanding of a var in CR is that once the var is brought into scope, any where in the report, the var stays in scope and retains what ever value was assigned to it, anywhere in the report and that to resetting the var is typically done in the group header. In my case, although I have multiple groups, there is only one group per var in my report. Thoughts?

Tom
 
Sorry, tom, you're right, shared variables are for subreports, I have a Hellish cold today and I'm not thinking.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top