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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default values for a date parameter 1

Status
Not open for further replies.

qwerty123987

Programmer
Mar 26, 2002
5
CA
Hey, I have a date parameter and I want to have a default value that is always 1 year prior to the current date. However, from what I know, I can only set the default values for a parameter to be a constant value (i.e. I can set the default date to be July 17, 2001, but this value will never change unless I change the report every day). Is there a way to do this from within Crystal?

Thanks
 
Sorry, there isn't a way short of using external code to do this.

If the start date is always one year prior to today, then you don't need a parameter.

You might consider using a text parameter which asks if they want to use the default of one year from today, and then you can derive this in a formula, if they say no, then they would need to fill out the next parm, which would be the date. Doesn't buy you much, and it adds a parm, but if they select use default (or you can have a list of choices such as last year, last quarter, month to date), they don't need to fill out the second parm.

Not much better I suppose...

-k kai@informeddatadecisions.com
 
Here's a kludge i've used: Set your default date parameter value to some far future date, like "01/01/2100" Conceal this value by creating a Description such as "This Date Last Year" and Show Description Only. In your selection formula: if ?DateParm = Date( "01/01/2100") then {MyDataDate} = DateAdd("yyyy", -1, CurrentDate) else {MyDataDate} = ?DateParm
 
Purdy clever workaround, Rogar!

The downside will be that if they select the default, the date will incorrectly prefill, but it's still the best solution I've heard of for allowing the entry of a date, OR use a single default.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top