Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Populate default value of static param with formul Post Reply Post New Topic
Author Message
ivilas21
Newbie
Newbie


Joined: 09 Feb 2012
Online Status: Offline
Posts: 3
Quote ivilas21 Replybullet Topic: Populate default value of static param with formul
     Posted: 10 Feb 2012 at 12:15am
Hi there,

i would like to give to a static parameter a default value from a function.

Specifically, i need to create a parameter, which by default contains the current date, so the user can *edit* the datetime, to for example, remove the time (leaving the date).
Is that possible?
I would like to express the default parameter value in a formula, like {!current_date}?

I've tried an alternative solution by creating a dynamic parameter from the query "select toString(datetime()) from table limit 1", which returns the current date as i want, but when launching the report, is not possible edit it...

some ideas?

thanks!

IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 10 Feb 2012 at 5:29am
you could try this
create 3 parameters in crystal
date (in type select date)
datetime(in type select datetime
parameter (in type select string, in values write
date
datetime
currentdate
in options set custom values to false)
in select expert put this
(if {?parameter} = "date" then {table.date} = {?date} else
if {?parameter} = "datetime" then {table.date}={?datetime} else
if {?parameter} = "current date" then {table.date}=currentdate)
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Feb 2012 at 11:56am
I guess I am just confused about the purpose of the parameter.
 
If it is a date, why not just the 'today' value.  If the only thing that the user is editing is the time, is your report time sensitive for the date, or do you just want all the values of a particular date?
 
you could make the parameter nullable and if null use the current datetime value or date, whichever is desired.
 
again, I'm just confused as it seems that you are doing a lot of work for what seems like a simple parameter...though it seems that I miss the obvious sometimes.
 
IP IP Logged
ivilas21
Newbie
Newbie


Joined: 09 Feb 2012
Online Status: Offline
Posts: 3
Quote ivilas21 Replybullet Posted: 12 Feb 2012 at 9:07pm
Hi! The main reason why should i do that, is because sometimes we need to fake the creation date. So, the parameter should be editable.

Thanks a lot for your answers, i've finally decided to create two params, one for choosing the date, a manual one, which will have the values "Current Date" and "manual".
If "manual" is selected, the the user will have to fill another parameter with the text of the date he wants.

Thanks a lot for pointing me to the right direction!
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