On Access Report: Need expr. that will count records where 2 chkbxs are "true"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cambar
    New Member
    • Jul 2010
    • 20

    On Access Report: Need expr. that will count records where 2 chkbxs are "true"

    Have an Access report in which Column A and Column B are checkboxes. Already have totals for each column and percentages. Now need to write an expression that will count the instances in which both boxes are checked for a record. Cannot seem to get there. I am not a programmer. Any help would be appreciated.
  • liimra
    New Member
    • Aug 2010
    • 119

    #2
    Solution/


    Although
    the question is not really clear here we go. Conditional expression can be the solution.
    Before I continue, you must know that the values for the check box or Yes/No Field are obviously yes or no/ ticked or unticked and in numbers language it is 0 & -1.
    Yes = -1 & No = 0


    I assume the names of the First Column And Second are "A" & "B" respectively, and both are check boxes (Please change Names to the exact names you have if they are different). Simply add a text box (third column) and write this expression inside:
    Code:
    =IIf([A]=0 And [B]=0,0,IIf([A]=0 And [B]=-1,0,IIf([A]=-1 And [B]=0,0,"1")))
    .

    Add the field which you want it to count the number of records which have both fields checked and paste this conditional expression:
    Code:
    =sum(=IIf([A]=0 And [B]=0,0,IIf([A]=0 And [B]=-1,0,IIf([A]=-1 And [B]=0,0,"1"))))
    This way is very flexible and you can adjust it to the way you want. Of course, it would be better to add this formula/expression in a query but for simplicity you can just add it to your report.

    Just to make everything will be clear, I have attached database which contains the above example. In the same database, I have added another report (called extended) which looks better (Tells where both are checked and gives the total)


    Regards,
    Ali
    Attached Files

    Comment

    • cambar
      New Member
      • Jul 2010
      • 20

      #3
      Thanks so much for your response. Adjusted my query to obtain the responses I needed. Your response, in part, helped me correct what was missing in the expression I was using.

      Comment

      Working...