Problems Using Count Queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • preeny8
    New Member
    • Jun 2008
    • 9

    #1

    Problems Using Count Queries

    I've run into a little problem with a form I'm trying to make, and I think it has to with my query design. Here's what I'm trying to do:

    I have query 1, query 2 and query 3. Query one counts all the rows with a "1" in column A, query 2 counts all the rows with a "2" in column A and query 3 counts all the rows with a "3" in column A.

    Basically, the problem happens if any of these counts happens to be 0. Instead of a 0 coming up as the result of the query, the results will just be blank.

    This normally wouldn't be a problem, but when I try to include these query results in another query or a form, it makes the whole query or form display nothing, not just the query that should be blank.

    Any thoughts?

    Edit: I'm using Access 2007
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    You can add a column to your query and set it to Expression. Use

    nz(Count([column A]),0)

    That will give you a zero even if there are no matching records.

    Comment

    • preeny8
      New Member
      • Jun 2008
      • 9

      #3
      Not quite getting it. Right now I have 2 columns in my query.

      Column 1 has:
      Table: "Master"
      Field: "ID"
      Total: "Count"
      And this column is showing

      Column 2 has:
      Table: "Master"
      Field: "Source"
      Total: "Group by"
      Criteria: "1"
      And this column is not showing.

      And the problem obviously comes when there are no values of "1" inside of the column named source.

      Are you saying I should ass in another column? What would I put in for the table and field? And where would I put in the expression you suggested? In criteria?

      Comment

      • ChipR
        Recognized Expert Top Contributor
        • Jul 2008
        • 1289

        #4
        Right, add another column. Set
        Total: "Expression "
        Field: "WhatEverNameYo uWant: nz(count(ID),0) "
        Table is blank.

        Comment

        Working...