Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Record selection based on parameters Post Reply Post New Topic
Author Message
LuisSantos
Newbie
Newbie
Avatar

Joined: 22 Jul 2008
Location: Australia
Online Status: Offline
Posts: 11
Quote LuisSantos Replybullet Topic: Record selection based on parameters
    Posted: 22 Jul 2008 at 11:00pm
Hi there,
 
I created a report with a record selection based on parameters. My problem is that report doesn't  select any records when I use conditional if.
 
I want to select records based on officer. To do that I create a parameter officer and want to do record selection basd on officer:
 
01 Andy
02 Angelo
03 Anne
 
My record selection is:
 
{auglbals.pst_yer} = {?Posting Year} and
not {@SuppressZeros} and
{auglsuba.opr_cap} = {?Operational or Capital} and
(if {?Officer} = 01 and {?Operational or Capital} = "O" then
{auglkdes.key_val} in ["1.11.04.06.01.01", "1.11.04.06.01.02"] and
not ({auglmast.lgr_acc} in ["03319", "03318"])) and
(if {?Officer} = 01 and {?Operational or Capital} = "C" then
{auglkdes.key_val} in ["1.11.04.06.02.01", "1.11.04.06.02.02"] and
not ({auglmast.lgr_acc} in ["04834", "04833"]) and
 
{auglsuba.acc_typ} <> "I") and
{auglkdes.alt_key} = 1
 
Report works fine if I use a record selection without conditional if:
 
{auglbals.pst_yer} = {?Posting Year} and
not {@SuppressZeros} and
{auglsuba.opr_cap} = {?Operational or Capital} and
{auglsuba.acc_typ} <> "I" and
{auglkdes.alt_key} = 1
 
Any suggestions or pointers appreciated.
 
-luis
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 23 Jul 2008 at 1:41pm
The problem is that you have two mutually exclusive conditions joined by an "and".  I would change this:
 
(if {?Officer} = 01 and {?Operational or Capital} = "O" then
{auglkdes.key_val} in ["1.11.04.06.01.01", "1.11.04.06.01.02"] and
not ({auglmast.lgr_acc} in ["03319", "03318"])) and
(if {?Officer} = 01 and {?Operational or Capital} = "C" then
{auglkdes.key_val} in ["1.11.04.06.02.01", "1.11.04.06.02.02"] and
not ({auglmast.lgr_acc} in ["04834", "04833"]) and
 
to this (changed highlighted in red):
 
((if {?Officer} = 01 and {?Operational or Capital} = "O" then
{auglkdes.key_val} in ["1.11.04.06.01.01", "1.11.04.06.01.02"] and
not ({auglmast.lgr_acc} in ["03319", "03318"])) or
(if {?Officer} = 01 and {?Operational or Capital} = "C" then
{auglkdes.key_val} in ["1.11.04.06.02.01", "1.11.04.06.02.02"] and
not ({auglmast.lgr_acc} in ["04834", "04833"])) and
 
Note the extra set of parentheses - because of the way SQL evaluates and's and or's, you MUST use parentheses to group the conditions in your or statement.
 
-Dell
IP IP Logged
LuisSantos
Newbie
Newbie
Avatar

Joined: 22 Jul 2008
Location: Australia
Online Status: Offline
Posts: 11
Quote LuisSantos Replybullet Posted: 23 Jul 2008 at 6:53pm
Hello Dell,
 
Thank you very much for your reply. Spot on !!
I got cross eyed after reading the statement over and over again.
 
Best regards,
-Luis
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.031 seconds.