Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Boolean result expected? Post Reply Post New Topic
Author Message
churdo
Newbie
Newbie


Joined: 28 Mar 2011
Online Status: Offline
Posts: 3
Quote churdo Replybullet Topic: Boolean result expected?
    Posted: 28 Mar 2011 at 3:36pm
I am a novice Crystal Report person and have been trying to figure out what I feel is a very simple report, but it is giving me fits.
 
I am searching for all entries which have a certain value and printing them out. However, I also want to grab those which do not have that value and still print them out.
 
For example, I want to pull the following entries from my DB:
 
1. All entries which are dated for yesterday.
2. All entries which have a value of SS1 for one of the keys.
3. All entries which do not have the value of SS1 (printed out with this field blank).
 
An example of the output for this report would look like:
 

Date      Name             Code

3/27       Smith              SS1
3/27       Maxwell          SS1
3/27       Johnson
3/27       Brown             SS1
3/27       Alcott               SS1
3/27       Howard     
 
I tried to do a formula like this:
 
if {rescode.code} = "SS1"
then "SS1"
else ""
 
However, I get an error because the formula should be returning a Boolean value, not a string.
 
How do I get this to work?
 
Thanks in advance!
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 29 Mar 2011 at 3:16am
Are you creating a (record) selection formula?

There are several formulas that expect boolean results, such as suppression formulas or selection formulas. There are more, but that should be all that matters for now.

If you want to filter the result set that the DB returns, then you will return True if you want to display it, and False if you don't.

You wouldn't be able to use a record selection formula for all three conditions because the third condition requires you to display all records. For this one, you would take your rescode formula and create it as a formula by right-clicking on the "Formula fields" tab in the field explorer and clicking new, then creating your formula there.

You can use a record selection formula to filter the records to only those that are dated yesterday, but it would be faster if you simply queried the DB for exactly those records that were dated yesterday.
IP IP Logged
churdo
Newbie
Newbie


Joined: 28 Mar 2011
Online Status: Offline
Posts: 3
Quote churdo Replybullet Posted: 29 Mar 2011 at 9:26am
Ah, I see! I am using the formula in the wrong place. Yes, this makes sense that the selection formula will require a boolean result.
 
I will try what you suggested.
 
Thank you!
IP IP Logged
churdo
Newbie
Newbie


Joined: 28 Mar 2011
Online Status: Offline
Posts: 3
Quote churdo Replybullet Posted: 29 Mar 2011 at 11:09am
I am creating the formula as you directed in the Formula fields tab. Now, I have a new problem.
 
The value I am searching for is actually in an array. Therefore, when I am searching for the value, I get multiple returns to the report.
 
My previous example shows exactly how I want the output to be produced.
 
Date      Name             Code
3/27       Smith              SS1
3/27       Maxwell          SS1
3/27       Johnson
3/27       Brown             SS1
3/27       Alcott               SS1
3/27       Howard     
 
However, when I am searching Code for my value, I am searching in an array. Therefore, the result I am getting is something like this:
 
Date      Name             Code
3/27       Smith              SS1
3/27       Smith
3/27       Smith
3/27       Maxwell          SS1
3/27       Maxwell         
3/27       Johnson
3/27       Johnson
3/27       Brown             SS1
3/27       Alcott               SS1
3/27       Alcott
3/27       Alcott
3/27       Alcott
3/27       Howard     
 
The number of times the line repeats depends on the size of the array holding the values.
 
How do I "skip" printing the irrelevant lines? If the value is not found anywhere in the array, I want to print the "blank" line once. If the value is found in the array, I want to print the line once with the code. All other instances should not be printed.
 
The main problem appears to be that functions MUST return something. I cannot have the function decide to just do nothing.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.015 seconds.