Solved

Checking data parameter is empty or null

Posted on 2008-10-20
4
496 Views
Last Modified: 2013-11-15
Hi,

I have a crystal report in which I want to allow the user to enter a date parameter, but if they don't I want to put in place a default date range.

My current code is attached.  I know I can't do the '' as the forumla expects a date type so won't compile and most likely the isnull is really only for checking database values, so thats prob out too, but it gives an idea of what I want to do.
//If no start date was given, then run the report for the reportPeriod of months from the given endDate.

if ( isNull({?Start_Date}) OR {?Start_Date} = '' ) Then 

    ( Date(DateAdd ("m",-{?reportPeriod_Months},cDate(year({@EndDate}), month({@EndDate}), 01))) ) 

else 

    {?Start_Date};

Open in new window

0
Comment
Question by:grahamcorp
  • 3
4 Comments
 
LVL 34

Accepted Solution

by:
James0628 earned 50 total points
Comment Utility
I don't think there's any particularly clean way to do this.

 If you don't set default values for a date parameter, then CR uses the current date as the default.  So, if the user doesn't enter a date, the parameter will have today's date.  That presumably won't help you unless you would never use today's date for that parameter.

 You can set a special default date (eg. 01/01/1900) for the parameter and check for that, but then when the report is run, the dropdown list of values for that parameter will list the default value(s) you entered, instead of giving you the usual calendar, so the user would have to type in the date they wanted manually instead of using the calendar.  If your users don't use the calendar when entering a date parameter, then maybe that's not a problem.  Otherwise, if the users want to use the calendar, they can uncheck the "pick from defaults" checkbox and get the calendar back, but it will start with the month and year currently in the parameter (eg. January, 1900).


 And, FWIW, you're right about IsNull ().  It only works on datasource fields, and maybe formulas that reference fields.

 James
0
 
LVL 34

Expert Comment

by:James0628
Comment Utility
For the record, I was referring to running the report from within CR 10.  If you're running the report via some other application, your options may be different.

 James
0
 
LVL 1

Author Comment

by:grahamcorp
Comment Utility
Thanks James,
I had a funny feeling this was going to be the case, so have change the report, instead of taking it a start and end date it will now take in a month time period and the report itself will work out the start and end dates.
0
 
LVL 34

Expert Comment

by:James0628
Comment Utility
Glad I was able to help, even if it was only to tell you "you can't get there from here".  :-)

 James
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now