Results 1 to 10 of 10
  1. #1
    Kath is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    5

    Question calculating with yes/no boxes


    I have used a simple yes/no box for some information in one of my tables. I want to write a query that can be included in a report that tells me how many of a group of selected records have "yes" checked. When I used "sum," I came up with negative numbers or zeros. These are not correct values. What do I need to do in the query to get a numeric values that equals the number of "yes" answers?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    Please tell us about your tables and the database generally in plain English.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    Maybe like:

    SELECT Sum(IIf([fieldname]=True,1,0)) AS CountYes FROM tablename;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Kath is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    5
    Two tables are involved in the query. The first lists basic information about the people who use our service. The yes/no box is in this table. The second table is in a subform, and tracks what day in a given month a client used our service. We must report certain information on the number of clients in a given month sorted according to city. The required information includes how many qualify as "yes" in the Yes/No field.

  5. #5
    Kath is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    5
    I must start by explaining that I created this database using the Microsoft Press Step by Step guide for Access 2010. I know next to nothing outside what is in the book. That said, I'm not sure where or how I would enter that formula when creating the query. Does it go in the "Criteria" row?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    It goes on the Field row. This is creating a field in query with expression but now I can see it's probably not what you want. Maybe something more like:

    SELECT ClientID, Count(ClientID) AS CountClients, Format([datefield], "yyyymm") AS MoYr, City FROM Clients INNER JOIN Services Clients.ClientID=Services.ClientID GROUP BY ClientID, Format([datefield], "yyyymm"), City HAVING Qualify = True;

    Or build a report and use its Sorting & Grouping features with aggregate calcs in group footer. This will allow display of detail records as well as summary calcs.

    Access Help has more guidelines on aggregate queries and building report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Kath is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    5
    I'm afraid what you have above is very confusing to me. I wouldn't even know where to write it and how to tell it I'm referencing two different tables. What I was hoping for was a "quick fix" that somehow translated the Boolean negatives into a "regular number." From the results in the test group I'm working with, it appears that the absolute value Boolean negative number is one less than the correct number. But before I try to write a formula to make this calculation, I wanted to know if there was something simpler and/or if what my test group shows does, in fact, make some logical sense to people who understand Boolean notation.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    What I showed is the SQL statement of a query. Use the Query Designer to build a query that joins tables. This is basic Access functionality. So is designing a report. If your book neglected these basics, then definitely need a better book.

    Could use Abs() function to eliminate the negative.

    Abs([fieldname])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Kath is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    5
    I do know how to build queries and reports accessing multiple tables, but only using Query Designer. Unfortunately, I don't know how to follow your SQL statement in query designer.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,640
    The example is an aggregate (Totals) GROUP BY query. Query in design view, click the Totals button on the ribbon. Your book should have more details.

    Or switch to SQL View and type SQL statement.

    Or build the suggested report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculating sum of selected option/combo boxes
    By SgtSaunders69 in forum Forms
    Replies: 4
    Last Post: 08-04-2014, 09:20 PM
  2. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  3. Replies: 4
    Last Post: 08-14-2012, 10:33 AM
  4. calculating
    By cade1980 in forum Access
    Replies: 3
    Last Post: 04-17-2012, 10:42 PM
  5. Calculating Age
    By Koyangie in forum Queries
    Replies: 2
    Last Post: 04-05-2012, 03:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums