Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Evaluate before Execute? Post Reply Post New Topic
Author Message
ChuckRW
Newbie
Newbie


Joined: 05 Jun 2009
Online Status: Offline
Posts: 4
Quote ChuckRW Replybullet Topic: Evaluate before Execute?
     Posted: 06 Jun 2009 at 11:07am
Hi,

Maybe this should be a Reply to my earlier post, but I thought it would be less confusing starting fresh.

First I'll phase this as concisely as I can, then I will explain more (for you patient saints)

How can I make this:

(totext({Activity.StartTime}) in {@runString}) = False (currently in Record Selection)

run BEFORE:

Global StringVar D;
D := (D & totext({Activity.StartTime})); (currently in {@runString} in the details section)

I need to suppress records that have a particular field duplictated. My idea is to create a global array of the the fields in question and check each new record for duplicates against that array. I'm too unsure of syntax to code this...SO..instead of an array I created a Global StringVar in to which I concatenate the potentialy duplicated field. I can check to see if the contents of the field, for each record, are contained in the StringVar.

It really seems as if it will work if I can get it to perform the evaluation BEFORE it concatenates the new value to the StringVar. As it is now, it performs the concatenation first and therefore, during the comparison, a duplicate is always found.

Here's what I have....

I have a formula field called {@runString}, in this field I put this code:

Global StringVar D;
D := (D & totext({Activity.StartTime}));

I put {@runString} in the details section. (I have tried it in group headers and footers and had no luck either)

In the Record Selection Formula Editor I put this code:

(totext({Activity.StartTime}) in {@runString}) = False

I hoped this would cause the report to not select records where this field had come before in another record (the records are sorted by another, non-duplicating, date field)

When this didn't work (the StringVar concatenation had already taken place), I tried puting it in the Section Editor to supprress records using a True value (totext({Activity.StartTime}) in {@runString}) = True. In this case the concatenation still takes place first.

I'm 99% sure this will do exactly what I need if I can get the concatenation to take place AFTER the evaluation. Ihave tried placeing the code in different place, but I'm very unsure of what options there are for controling when these things execute.

Any help would be GREAT!

Thanks.

Chuck
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Jun 2009 at 6:38am
OK, how about this.  In the row suppression formula...
local booleanvar sup := false;
shared stringvar D;
 
if instr(D, totext({Activity.StartTime})) >0 then
 sup:= true;
 
D :=D + totext({Activity.StartTime});
sup
 
this should work. Give it a try and let us know.
IP IP Logged
ChuckRW
Newbie
Newbie


Joined: 05 Jun 2009
Online Status: Offline
Posts: 4
Quote ChuckRW Replybullet Posted: 08 Jun 2009 at 1:21pm
Thanks very much for responding.
 
I did find a solution. It looks like your suggestion might be a more elegant way of doing something similar, and I would truely like to understand it, but my way is working and I have to get this thing looking pretty now and delivered.
 
What I did is cause the StringVar that gets checked in Record Selection to be populated one iteration late.
 
Now I have this in a field in the details section:
 
Global StringVar D;
Global StringVar D2;
if ((totext({Activity.StartTime}) in D) = True) then
D2 := (D2 & totext({Activity.StartTime}));
D := (D & totext({Activity.StartTime}));
 
and this in the Record Selection:
 
(totext({Activity.StartTime}) in D2) = False
 
This works perfectly in testing. Let me know if you see anything wrong besides uglyness....
 
Thanks again for your time.
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Jun 2009 at 1:30pm

If it's working, then life is fine :)

IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum