Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Optional Parameters in formulas Post Reply Post New Topic
Author Message
bff7755a
Newbie
Newbie


Joined: 23 Nov 2009
Location: Russian Federation
Online Status: Offline
Posts: 2
Quote bff7755a Replybullet Topic: Optional Parameters in formulas
    Posted: 23 Nov 2009 at 6:39am
How can I check, if the optional parameter present.

When I try use this code:

if not IsNull({@DATERUN}) then
    formula = DateTimeValue ({@DATERUN})
else
    formula = DateTimeValue(0)
end if

I have an error when I run a report with no value for parameter DATERUN.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Nov 2009 at 2:58pm
Do you mean how can you return all values if nothing is selected or = to whatever day is selected? I do not see your parameter in your code so I going to gess your formula was meant to be the parameter.
In the select expert use I think you could use:
IsNull({?DateRun}) or {?DateRun}={table.datefield}
IP IP Logged
bff7755a
Newbie
Newbie


Joined: 23 Nov 2009
Location: Russian Federation
Online Status: Offline
Posts: 2
Quote bff7755a Replybullet Posted: 23 Nov 2009 at 11:00pm
Originally posted by DBlank

Do you mean how can you return all values if nothing is selected or = to whatever day is selected? I do not see your parameter in your code so I going to gess your formula was meant to be the parameter.
In the select expert use I think you could use:
IsNull({?DateRun}) or {?DateRun}={table.datefield}


Sorry. I mean, {?DateRun}, of course. The problem is that when DateRun is not set, I couldn't use IsNull() for testing it. Crystal says "Parameter value not defined".
IP IP Logged
foyst
Newbie
Newbie
Avatar

Joined: 24 Nov 2009
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote foyst Replybullet Posted: 24 Nov 2009 at 5:32am
Have you tried using HasValue instead of IsNull?
 
if HasValue({?DATERUN}) then
    formula = DateTimeValue ({?DATERUN})
else
    formula = DateTimeValue(0)
end if
 
Believe that should do it, apologies if not I didn't get chance to test it!
Note that I believe this function only came about in Crystal Reports 2008, so won't work in earlier versions.
 
HTH
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Nov 2009 at 6:46am
I think some versions do not allow you to leave an empty param at run time. If the param is in the report you have to enter a value.
If this is the case try using a default value (like 01/01/1900) which in your select statement would be set to ignore the value (like the ISNULL).
{?DateRun}=Date(1900,01,01) or {?DateRun}={table.datefield}
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.016 seconds.