Access DB - Crystal Report - Null Date issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • metsu962
    New Member
    • Apr 2008
    • 2

    Access DB - Crystal Report - Null Date issue

    Okay so I've been tearing my hair out for weeks over this issue. What I have is a Crystal Report that's showing a table pulled from an Access Database. The database is a HUGE pile of junk and it has a text based Date field!! Unbelievable.

    This causes my Crystal Report a bunch of problems as I have to convert the date text data to date and compare it to the user inputted date to find records between the inputted dates. All would be swell if some of the entries were not blank!

    Here's what I have when the user runs a filter and filters a date:

    sQuery = "CDATE({tablena me.datefield}) >= CDATE('01/01/2008')";
    CrystalReportvi ewer1.Selection Formula = sQuery;
    CrystalReportvi ewer1.RefreshRe port();

    It works fine if the date is not empty and I've tried to tell the Report "Convert Database Null Values to Default" but all that nets me is an error message of
    "Bad Date Format String" because of the blank field trying to be converted. It appears the Convert Database Null Values does not work, or is not helpful at all on this end.

    Please help if you have a solution on what I can do with the blank date fields! Thank you so much in advance.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Originally posted by metsu962
    Okay so I've been tearing my hair out for weeks over this issue. What I have is a Crystal Report that's showing a table pulled from an Access Database. The database is a HUGE pile of junk and it has a text based Date field!! Unbelievable.

    This causes my Crystal Report a bunch of problems as I have to convert the date text data to date and compare it to the user inputted date to find records between the inputted dates. All would be swell if some of the entries were not blank!

    Here's what I have when the user runs a filter and filters a date:

    sQuery = "CDATE({tablena me.datefield}) >= CDATE('01/01/2008')";
    CrystalReportvi ewer1.Selection Formula = sQuery;
    CrystalReportvi ewer1.RefreshRe port();

    It works fine if the date is not empty and I've tried to tell the Report "Convert Database Null Values to Default" but all that nets me is an error message of
    "Bad Date Format String" because of the blank field trying to be converted. It appears the Convert Database Null Values does not work, or is not helpful at all on this end.

    Please help if you have a solution on what I can do with the blank date fields! Thank you so much in advance.
    Perhaps best to create a query (qryX) in Access using the NZ() function like:
    Code:
    select *, IIF(IsNull([Datefield]),Date(),CDate([Datefield])) as DateConverted from tblX
    Now Crystal can point to the query and use [DateConverted] from qryX

    Nic;o)

    Comment

    • metsu962
      New Member
      • Apr 2008
      • 2

      #3
      Nico! You are godsend, thank you so much! I made a slight variation to your code as I found out I was getting "#Error!" thanks to the blank date fields. Apparently the field does not allow "null" and the fields were not null they were just blank? No character spacing..I have no idea, but anyway instead of doing "IIF(IsNull ", I wrote IIF([DateField]=''). Works like a charm now, thank you soo much!

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        Glad I could help and success with your application !

        Nic;o)

        Comment

        Working...