Print Page | Close Window

Global Variables

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21003
Printed Date: 30 Apr 2024 at 9:13pm


Topic: Global Variables
Posted By: Empeefree
Subject: Global Variables
Date Posted: 26 Aug 2014 at 8:45pm
Formula Fields:

//SetSectionIntro, Set Section to Intro.
Global StringVar SectionName;
SectionName := "Introduction";

//SetSectionRev, Set Section to Revision.
Global StringVar SectionName;
SectionName := "Revision";

//GetSection, returns the section name
Global StringVar SectionName;

The first two formula fields set the value of the global variable and the last formula field return the global variable value when called.

Outline:
My report have 2 group footer sections where I call the SetSection formula in each of the group footers. The global variable is not updating and only reflects the first SetSection call "Introduction".

Report layout:

Report Header
Page Header
Group Header #1
Details
Group Footer #1a
SetSectionIntro
GetSection //Returns the correct value as "Introduction")
Group Footer #1b
SetSectionRev
GetSection //Returns the incorrect value as "Introduction" and should be "Revision"
Report Footer
Page Footer

Any pointers or assistance is greatly appreciated. Let me know if that does not make sense?



Replies:
Posted By: z9962
Date Posted: 27 Aug 2014 at 12:37am

I am not sure what you are trying to achieve here by using a variable? Why not just use a text box Introduction in GF1a and a second one Revision in GF1b?



Posted By: Empeefree
Date Posted: 31 Aug 2014 at 7:55am
Thanks for response z9962. I'm using a stored procedure to write the GetSection value to a database. I've managed to sort with another method.


Posted By: lockwelle
Date Posted: 05 Sep 2014 at 12:35pm
since the syntax is correct, my thought would be Crystal is calling the Read formula before the Set.

just for fun, you could try making another group footer section and putting the set formula there (suppress the footer so it doesn't show) and then checking if the get formula return correctly....

for next time.

just a thought



Print Page | Close Window