Print Page | Close Window

global variable resets at group change

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=21258
Printed Date: 06 May 2024 at 1:09pm


Topic: global variable resets at group change
Posted By: rvroth
Subject: global variable resets at group change
Date Posted: 06 Jan 2015 at 11:24pm
Hi,

I have some issue with a report and hope you can help me with this ...

The report looks like:
RH
PH
GH1 suppressed
GH2a
GH2b
Da
Db
GF2a suppress formula beneath
GF2b suppress formula beneath
GF1 suppressed
RF
PF

The reason of G2 being a and b is that for each group 2, 2 pages need to be printed (with slightly different informations).

To know which page to print when, I use a global variable swtva which has values 0 to print pages a or 1 to print pages b.

This variable is managed into formulas:

swtva_init placed in RH:
Global NumberVar swtva;
swtva := 0;

swtva_set0 placed in GF2a:
whileprintingrecords;
Global NumberVar swtva;
swtva := 1;

swtva_set0 placed in GF2b:
whileprintingrecords;
Global NumberVar swtva;
swtva := 0;


There are 2 suppress formulas in Section Expert for G2a and G2b sections (H,D,F):
G2a:
Global NumberVar swtva;
if swtva = 1 then true else false

G2b:
Global NumberVar swtva;
if swtva = 0 then true else false



My first issue is that the footers (GF2a and GF2b) never get printed.

My second issue is that, if I delete the formula in GF2a so it's never suppressed, then swtva is correctly set to 1 at the end of GF2a, but is reset to 0 at the beginning of PH, so that the second page never gets printed.

I'm very puzzled here. I'm sure I'm doing something wrong, but can't figure it out.

Any help will be greatly appreciated.

Thanks
rv



Replies:
Posted By: rvroth
Date Posted: 06 Jan 2015 at 11:38pm
I just solved this issue by changing the formula in GF2a and suppressing GF2b.

formula is:
whileprintingrecords;
Global NumberVar swtva;
//swtva := 1;
if swtva = 0 then swtva := 1 else swtva := 0

But I'm having another issue now ... maybe I'll come back
;)


Posted By: rvroth
Date Posted: 06 Jan 2015 at 11:50pm
The new issue is that at each G2 change the report printed switches as well. i.e.
initial group --> report a
next group    --> report b
next group    --> report a
a.s.o.

I don't know if I went the correct path to achieve my goals being at end: in each G2, print report a and maybe report b if needed.

Does anyone have an idea?

Thanks



Print Page | Close Window