Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Null parameters Post Reply Post New Topic
Author Message
luisbap
Newbie
Newbie


Joined: 19 Feb 2010
Online Status: Offline
Posts: 5
Quote luisbap Replybullet Topic: Null parameters
     Posted: 19 Feb 2010 at 4:46am
Hello,
I have a report with 3 different parameters:
Date A
Date B
Date C
 
The user, in another applications must choose one of these dates, but only one.
What is happening is that the other 2 dates must have something. How can I allow the other 2 parameters to be left blank?
 
Thanks in advance
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Feb 2010 at 6:52am

depends on how the report is structured.  The other dates can be NULL and then when you filter the data, you can determine which date to use and what it means. 

If you are getting the data from a stored proc, all of the logic would go in the proc.
 
or you could pass the date chosen and the type of date, since the date must signify something.
 
The blank dates, typically, would be given a NULL value and you would work around them.  If they are needed, you could reassign their value based on whether or not they are NULL.
 
As you can tell, there are many ways to deal with only 1 date out of 3 being set. It's up to you and the report to determine which method best suits your needs.
IP IP Logged
luisbap
Newbie
Newbie


Joined: 19 Feb 2010
Online Status: Offline
Posts: 5
Quote luisbap Replybullet Posted: 19 Feb 2010 at 7:15am
Thanks for your answer Lockwelle,
let me put the question in another way (I'm kind of newbie, so please be patiente).
I'm using CRXI r2 with an Oracle database (no store procedures) and I'm talking about "optional parameters".
 
When the user runs the report he can choose from DateA and/or DateB and/or DateC (among other parameters).
What is happening is that all fields are mandatory and I can't left any date blank or the report will not run.
 
I tried to use a default value for dates and in 'Select Expert" used a formula like the one below for all 3 dates:
 
If {?DateA} = '31-12-2099' then
True
else
{table.DateA} = {?DateA}
 
 
I left 2 dates with 'default values' and the DateC with a correct date. It should return all records with the DateC, but it is returning all records without any filter.
 
What went wrong?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Feb 2010 at 7:27am
well, the true means to include the record, and if you have 3 sets of the above if statement, it will probably take the last one as the 'final' determination.
 
I would try something like:
local booleanvar da;
local booleanvar db;
local booleanvar dc;
 
If {?DateA} = '31-12-2099' then
da := True
else
da := ({table.DateA} = {?DateA});
 
repeat for all dates...
 
if da and db and db then
 true
else
 false;//this if statement, as it is the 'return' value can be abbreviated to :
da and db and dc (I think)
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Feb 2010 at 7:31am
I think and easier approach here would to use 3 parenthed OR statements joined by ANDS (credit to Hilfy on this):
({?DateA} = '31-12-2099' or {table.DateA} = {?DateA})
AND
({?DateB} = '31-12-2099' or {table.DateB} = {?DateB})
AND
({?DateC} = '31-12-2099' or {table.DateC} = {?DateC})


Edited by DBlank - 19 Feb 2010 at 7:32am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 Feb 2010 at 7:39am
yes, that would definitely work, but there are times I keep it simple for both my head, and so that others can see it simplied.
 
I am sure that I would do something similar.
IP IP Logged
luisbap
Newbie
Newbie


Joined: 19 Feb 2010
Online Status: Offline
Posts: 5
Quote luisbap Replybullet Posted: 19 Feb 2010 at 7:46am
Thanks DBlank, that easier approach worked out fine.
Thanks also to lockwelle for the patiente and time spent.
Best regards for both of you
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