Solved

Checking data parameter is empty or null

Posted on 2008-10-20
4
524 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 35

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 35

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 35

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through setting up a JasperReports Server using the AWS EC2 instance, and this article will cover some basic administration tasks I had to perform.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

695 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