Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Flagging A Specific Value Post Reply Post New Topic
Author Message
petpil
Newbie
Newbie


Joined: 06 Dec 2007
Location: Canada
Online Status: Offline
Posts: 4
Quote petpil Replybullet Topic: Flagging A Specific Value
     Posted: 07 Dec 2007 at 9:12pm
I am creating a report in which I want a message to be printed in the footer if a certain string value appears in any record.  The problem I seem to be running into is that every record is being checked so I am getting the result based on the last record only.  Is there a way to stop checking records once a condition has been satisfied and have the message print in the footer section?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Dec 2007 at 10:32pm
I would create a formula that checks the current record for that string. If the record exists, then set a variable to be true. Put this formula in Details section. Next, I would create a formula which says that if that variable is true, then print the appropriate text. Put this formula in the Footer section.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
petpil
Newbie
Newbie


Joined: 06 Dec 2007
Location: Canada
Online Status: Offline
Posts: 4
Quote petpil Replybullet Posted: 08 Dec 2007 at 10:32am
Yes, that is the premise I have been using.  However, I have four details sections (each one for a different type of record).  The first section is the one that I want to check for the specific string.  I have been able to determine that that part works fine.

Where it seems to be getting messed up is when it comes across a record that fits the criteria of one of the other detail sections.  It seems to be "resetting" the variable at that time so by the time it reaches the end of the report and is ready to print the appropriate text in the footer, the variable has been reset.

Of course, this does not occur if the report only had records that pertained to the first detail section.  In that case it works fine.

I am quite new to Crystal Reports so, if this is an obvious error on my part, I apologize.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 08 Dec 2007 at 12:31pm
That can be a bit tricky if you are new to CR. In your code, make sure you are not resetting it in the formula that is in the Details section. If you need to reset the formula, do it in a group header section or page header. Also, your code should not be an If-Then-Else where the Else part resets it. You only do the part that sets it. Here is an example:
BooleanVar ShowFlag;
If {field}= "something" Then
   ShowFlag := True;

That way, once the variable is set to true, it won't get reset back to false on the next record.
If a record from another Detail section is resetting it for some reason, then either don't put the formula in that section or add another condition to skip the test if you are on a record that doesn't  apply.
BooleanVar ShowFlag;
If {recordtype} = "a" Then
   If {field}="something" Then
      ShowFlag:=True;


Since you are new to CR, you should check out chapters 5-7 in my book Crystal Reports Encyclopedia. It will make you an expert on formulas.


Edited by BrianBischof - 08 Dec 2007 at 12:31pm
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
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