Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking 2 flags at a time

Status
Not open for further replies.

addygoyal

Programmer
Apr 24, 2003
21
ZA
hey guys a difficult problem to expain i hope i get some solution
I have a string parameter to which only two values 'Y' or 'N' can be passed
i.e. ?Paramter = 'Y' or 'N'
If value 'Y' is passed i want to select all the records of a particular type this i ve accomplished by using

" and if (uppercase({?Parameter}) = 'Y' ) then true "

in the formula

and now if the value of {?Parameter}= 'N'
i want to check a database field which also stores values 'Y' or 'N' and if the value of database field is
'N' then i want only the records with the value for this feild as 'N' to be printed.

so the crux is

if ?Paramter = 'Y' then print all the records (ie both the records with value for {Database field} = 'Y'or 'N'}

but if ?Paramter = 'N' then print only the records where {Database field} = 'N'}
i guess that explains it
Hopin you guys turn up with some solution
 
Try something like this, substituting your own fields:

if {?parameter} = "Y" then {table.customerID} > 0 else
if {?parameter} = "N" then
if {table.yesno} = "N" then {table.customerID} > 0

-LB
 
I would make it into one If-then block

If uppercase({?parameter}) = "N" then
{Table.YesNo} = "N"
else
True

Jim Broadbent
 
Jim's solution makes sense, and it should pass the SQL to the database with one slight modification:

If uppercase({?parameter}) = "N" then
{Table.YesNo} = "N"
else
If uppercase({?parameter}) <> &quot;N&quot; then
True

Crystal is inconsistent about pass thru SQL, and if this is the only criteria in the record selection formula, it may pass it anyway, but if you have multiple criteria, fully qualify both sides for the best results.

-k
 
SV- I am curious....why add the second IF??? I don't see the purpose...if it isn't &quot;N&quot; then you just want it to return all the records.

How is adding the second IF improving that??

Jim Broadbent
 
It increase the likelihood of pass through SQL. I've posted many times here resolving SQL pass through by using this technique, believe me, I don't do it for efficient coding, it's to get around the Crystal *peculiarities* when building SQL pass through ;)

-k
 
i ve tried both Jim's and SV's solution but still iam not able to get the desired records i am gettin all the records by paasing Y to parameter
ie uppercase({?parameter}) = &quot;Y&quot;
but i am not able to get the records where {table.yesno}= 'N'
by passing N to the parameter
So guyz any more ways
 
You probably have nulls in your data base

Go to report options and enable the &quot;convert nulls to default&quot;


BY THE WAY...WHY DID YOU START A NEW THREAD!!!

If you want more cooperation you won't do stuff like that.

Jim Broadbent
 
sorry for the late addition but would this not pass??

({?Parameter} = 'Y' OR {Database field} = {?Parameter})

seems simpler to me to avoid all the if statements..

Lisa
 
hey jim sorry for starting a new thread i did that coz i saw other ppl doing that and good that thread has been deleted
And thanks to you all guys i ve finally solved my problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top