Query Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbsevans
    New Member
    • Oct 2006
    • 6

    Query Question

    I have an existing database with one field with financial figures ($00,000).
    How do I setup a query where I can find those fields where there are either no entries (null)? or $0.00 dollar entries?

    I realize its an OR operator within that particular column but how are the figures expressed?

    Thanks.
  • VALIS
    New Member
    • Oct 2006
    • 21

    #2
    Originally posted by mbsevans
    I have an existing database with one field with financial figures ($00,000).
    How do I setup a query where I can find those fields where there are either no entries (null)? or $0.00 dollar entries?

    I realize its an OR operator within that particular column but how are the figures expressed?

    Thanks.
    Try typing a version of the following in the SQL view of the query.
    You need to substitute your table name and field name for tbl & Field.

    SELECT tbl.*
    FROM tbl
    WHERE (((tbl.Field) Is Null)) OR (((tbl.Field)=" 0"));

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32636

      #3
      Another good answer Valis, but you may come unstuck on the test for zero.
      This depends heavily on what type of field 'Field' is.
      I'm going to assume that the field is a simple numeric field and then I can forget about formatting.
      If it's actually a string (formatted currency value for instance) then I would suggest converting the result to a numeric as CDbl([Field]). This avoids any hiccoughs with data entry or confusion over the exact format (it's also more reuseable code).
      Also, I will use the Nz() function to avoid having to use 'OR' and to do it in one test.
      Code:
      SELECT *
      FROM tbl
      WHERE (Nz([Field], 0) = 0);
      or, for the string version
      Code:
      SELECT *
      FROM tbl
      WHERE (Nz(CDbl([Field]), 0) = 0);

      Comment

      Working...