Print Page | Close Window

Boolean variable reset

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19648
Printed Date: 04 May 2024 at 6:51am


Topic: Boolean variable reset
Posted By: nalfein
Subject: Boolean variable reset
Date Posted: 13 Jun 2013 at 1:44am
Hi I've create a field with this code

WhilePrintingRecords;
Booleanvar flg_stampa_piede_s6:=false;

And put in the header

In the details I've a field that must be checked with this formula

WhilePrintingRecords;
if instr ({stdoc_righe.rig_parte},"S6")>0 then
BooleanVar flg_stampa_piede_s6:=true;
flg_stampa_piede_s6

So if in the field there's "S6" word the variable change to true.
And it works fine. I've put the field in the details and the true appear.

In the report footer I've another field with suppress code in this way

BooleanVar flg_stampa_piede_s6;
if flg_stampa_piede_s6 = true then false else true;

So if the variable is true (and the word is in the report) then print it.

Unfortunately it seems not working. After some try I've tried to check the variable value and appears that in the page footer is false. So it seems that for some reason the variable doesn't remain in the same state of the details.

Am I doing something wrong?

Thanks for answers
[IMG]smileys/smiley1.gif" align="middle" />


EDIT

After many test it seems that it takes the last row without considering the remaining.
The strange part is that I put visible the variable in the details and at the same time in the report footer and obtain that thing

blabla [false]
blablas6 [true]
blabla [true] *correct because when the variable change doesn't change anymore

variable in the page footer.... [false]!!!

It seems that is considering only the last row despite the value in the last row is true.

Really dunno...



Replies:
Posted By: kevlray
Date Posted: 13 Jun 2013 at 5:17am
One, I never have good luck with my variables to default as global.  If I want the variable to keep it's value.  I set my variables to be shared (i.e, Shared BooleanVar flg_stampa_piede_s6;).  Secondarily, just because I am an old programmer.  I always define my variables at the beginning of the code (shouldn't matter though).


Posted By: nalfein
Date Posted: 17 Jun 2013 at 9:07pm
Nm. Was my fault.
I've put the variable declaration in the detail row so he'll reset every time the value.
I'm stupid



Print Page | Close Window