Consulting

Results 1 to 5 of 5

Thread: Counting String Null Values

  1. #1
    VBAX Regular
    Joined
    Aug 2008
    Location
    Houston
    Posts
    16
    Location

    Arrow Counting String Null Values

    I am writing a Crystal Report that is counting a string value field; it will not recognize/count the null values. For example, if F2 is a server name and one field is empty, it just eliminates it from the count; I need to include it.

    Any suggestions?

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Personally I would just edit the source query to pull the field a little differently. Instead of just pulling the field "raw" I would use the Replace expression and replace null with a string saying something "Name not found" or something suitable. That should get it included in your count. Check here for more detail on the Replace function if you have not used it: http://msdn.microsoft.com/en-us/library/ms186862.aspx
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    VBAX Regular
    Joined
    Aug 2008
    Location
    Houston
    Posts
    16
    Location
    Crystal uses an ODBC connection to a db table. If I add the replace function to the formula editor as you suggest I get a boolean result, which is still blank.
    SELECT REPLACE({db.F3},'',"blank")

  4. #4
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Hmm you shouldn't be getting a boolean result, double check your syntax your must be accidently performing a comparison. But while you are double checking, also check the documentation on Replace, and make sure it handles Nulls. The more I think about it you might actually need to be using If IsNull etc.
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  5. #5
    VBAX Tutor Mavyak's Avatar
    Joined
    Jul 2008
    Posts
    204
    Location
    For SQL Server you can use the ISNULL() function.
    SELECT ISNULL(DB.F3, '')
    For MS Access you can use the Nz() function:
    SELECT Nz(DB.F3, '')

Posting Permissions

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