Solved

Checking data parameter is empty or null

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

Independent Software Vendors: 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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to increase the row limit in Jasper Server.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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