Solved

Checking data parameter is empty or null

Posted on 2008-10-20
4
514 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal Reports--SubReport 3 61
Dynamic Image won't display if no data is returned 11 65
Multiple Parameters in Crystal 11 78
Date Formula: Last business day - 2 of prior month 12 57
Problem Statement In an SAP BI BO Integration project when a BO universe is built on a BEx query, there can be an issue of unit & formatted value objects not getting generated in a BO universe for some key figures. This results in an issue whereb…
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 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