Solved

Checking data parameter is empty or null

Posted on 2008-10-20
4
507 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
ID: 22756469
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
ID: 22756618
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
ID: 22756622
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
ID: 22756726
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Hi, I am very much excited today since I'm going to share something very exciting Tool used for Analytical Reporting and that's nothing but MICROSTRATEGY. Actually there are lot of other tools available in the market for Reporting Such as Co…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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