Print Page | Close Window

Boolean Allow Multiple Values

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=6402
Printed Date: 29 Apr 2024 at 12:37am


Topic: Boolean Allow Multiple Values
Posted By: SDNewsome
Subject: Boolean Allow Multiple Values
Date Posted: 19 May 2009 at 11:21am
How do I create a parameter based on a boolean field that will allow the user to select multiple values?  I'm using Crystal Reports XI.



Replies:
Posted By: DBlank
Date Posted: 19 May 2009 at 11:37am
Do you mean you want them to be able to Select between 3 options: "True", "False" or both "True and False"?


Posted By: SDNewsome
Date Posted: 19 May 2009 at 11:39am
Exactly.  I want the user to be able to select "True", "False", or both "True" and "False".


Posted By: DBlank
Date Posted: 19 May 2009 at 11:52am

Create a parameter as Text with those 3 options. In your select statement handle the 3 items to get the appropriate records.

If {?parameter}="True" then {table.boolean field}=true else
If {?parameter}="False" then {table.boolean field}=False


Posted By: SDNewsome
Date Posted: 19 May 2009 at 12:53pm

I created a static, string parameter {?Active} with no Value Field and the Values of "true" and "false".  I allowed multiple values.  The Select Expert formula is:

{EMPMAST.CLASS} = {?Class} and (sworn, non-sworn, civilian, etc.)
If {?Active}="True" then {EMPMAST.HIDE}=true else
If {?Active}="False" then {EMPMAST.HIDE}=False and
{empmast.hired}={?daterange} and
{EMPMAST.UNIT} startswith "DEP" and (this is no longer working)
{EMPMAST.UNIT} = {?District}
 
The parameter screen looks great, but the data that appears in the report is incorrect. 


Posted By: DBlank
Date Posted: 19 May 2009 at 12:57pm
{EMPMAST.CLASS} = {?Class} and 
{empmast.hired}={?daterange} and
{EMPMAST.UNIT} startswith "DEP" and
{EMPMAST.UNIT} = {?District} and
(If {?Active}="True" then {EMPMAST.HIDE}=true else
If {?Active}="False" then {EMPMAST.HIDE}=False else
{EMPMAST.HIDE}={EMPMAST.HIDE})


Posted By: DBlank
Date Posted: 19 May 2009 at 2:21pm
Sorry, I should have explained the change but was running into a meeting when i answered earlier and wanted you to be able to fix it...
You ned to make the "if-then-if" a single evaulation in the overall selection process. In your statement, once it found an "if-then" that it could use (which would be all records because all records would be one of the 3 options) it stopped evaluating the rest of your selection criteria.
By adding () around the full if-then-if statement it will evaulate it as a single part of the criteria. I also added the somewhat bogus final else of "{EMPMAST.HIDE}={EMPMAST.HIDE}" so it won't choke on the "and" prior to the if then statement if it didn't find true or false. It may not be needed but I think it is...


Posted By: SDNewsome
Date Posted: 20 May 2009 at 10:17am
That fixed it.  Thank you very much!!!



Print Page | Close Window