• Filter a report for null? (Office XP)

    Author
    Topic
    #413126

    I want to filter my report to display all records with null values in the “Completed On” column….here’s what I’ve *started* working with…I need a little nudge in the right direction – Thanks!

    Dim stDocName As String
    Dim strCriteria As String
    stDocName = “AwardsMatrix”
    strCriteria = “[Completed On]= 0”

    DoCmd.OpenReport “AwardsMatrix”, acPreview, acReadOnly, strCriteria

    Viewing 1 reply thread
    Author
    Replies
    • #908944

      Null is different from zero (0). Zero is a specific number, while null means that data are missing. Don’t think of null as “nothing” but as “it could be anything”. Therefore, you cannot check for null values by using

      [Completed On]=0

      as criteria, neither by using

      [Completed On]=Null

      To test for nulls, you must use

      [Completed On] Is Null

      “Is Null” is a fixed expression (to test for non-null values, you would use another fixed expression “Is Not Null”). So try

      strCriteria = “[Completed On] Is Null”

      • #908946

        I had tried Is Null….but I’d done it like this: IsNull, messing me up….thanks a lot!

        • #908952

          I admit it is slightly confusing. In a query, and hence in WhereCondition arguments, you use Is Null:

          [FieldName] Is Null

          but in expressions, for example in the control source of a text box on a form, or in VBA code, you use the function IsNull:

          =IIf(IsNull([FieldName]),"This","That")

          • #909043

            Thanks for the info! There is a LOT to learn about these programs….geez

          • #909044

            Thanks for the info! There is a LOT to learn about these programs….geez

        • #908953

          I admit it is slightly confusing. In a query, and hence in WhereCondition arguments, you use Is Null:

          [FieldName] Is Null

          but in expressions, for example in the control source of a text box on a form, or in VBA code, you use the function IsNull:

          =IIf(IsNull([FieldName]),"This","That")

      • #908947

        I had tried Is Null….but I’d done it like this: IsNull, messing me up….thanks a lot!

    • #908945

      Null is different from zero (0). Zero is a specific number, while null means that data are missing. Don’t think of null as “nothing” but as “it could be anything”. Therefore, you cannot check for null values by using

      [Completed On]=0

      as criteria, neither by using

      [Completed On]=Null

      To test for nulls, you must use

      [Completed On] Is Null

      “Is Null” is a fixed expression (to test for non-null values, you would use another fixed expression “Is Not Null”). So try

      strCriteria = “[Completed On] Is Null”

    Viewing 1 reply thread
    Reply To: Filter a report for null? (Office XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: