CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2010
    Posts
    4

    Crystal report handling null values

    Hi everyone!!
    This is my first post and would like to say Hello to everyone out there.
    I am using embedded Crystal Report in VS2005. My problem is that i am populating the data from a table in SQL Server 2000 (for some reasons)!! Everything is working fine except that i am not able to display some text where the fields are empty or blank.
    For. e.g. I have a field called TIMEIN Type (Char) with (allow nulls) value checked in sql table .

    What i want is that if this field is empty it should display "ABSENT". I used the following formula but the field remians empty by right clicking the field and format object and then the icon next to Display String - guess this is the right way to do??

    If Isnull({Attendance.TIMEIN}) or
    instr({Attendance.TIMEIN}, "") = 0 or
    UCASE({Attendance.TIMEIN}) = "" or
    Trim({Attendance.TIMEIN}) = "" Then "ABSENT"
    Else {Attendance.TIMEIN}

    I have also CHECKED and UNCHECKED the "Convert Database Values to Default" in the ReportOptions but still no result.


    I would appreciate any help!!
    Cheers
    irfi

  2. #2
    Join Date
    Apr 2008
    Location
    Pittsburgh
    Posts
    103

    Re: Crystal report handling null values

    Try placing a space between the " ". Don't know why that works sometimes for me, but I suspect that is because our database was not very well designed, and users would use a space to delete data.

  3. #3
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Crystal report handling null values

    In this case the best is to configure Crystal Reports
    Menu / File / Option / Reporting / check Convert Database NULL values to Default

    After this, all you have to do is ask for an empty string, as :
    Code:
    If Trim({Attendance.TIMEIN}) = "" Then "ABSENT" Else {Attendance.TIMEIN}
    JG

  4. #4
    Join Date
    Jun 2010
    Posts
    4

    Re: Crystal report handling null values

    Thank you for your suggestions but unfortunately none is working for me. Just don't know whats going wrong!

  5. #5
    Join Date
    May 2003
    Location
    Islamabad, Pakistan
    Posts
    284

    Re: Crystal report handling null values

    if not isnull({Attendance.TIMEIN}) AND trim({Attendance.TIMEIN}).length > 0 then
    {Attendance.TIMEIN}
    else
    "ABSENT"
    If this post is helpful, then, Rate this Post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured