Results 1 to 13 of 13
  1. #1
    ajk825 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    15

    is it possible to count bools separately for comparison?

    Hello I'm new to access so please be gentle... I have an access database that stores recipes. 2 of my table are RECIPES and FEED_BK with the primary relationship being(RECIPE.RecipeID FEED_BK.RecipeID_FK)... in FEED_BK i have a column "IsDwnlded" which is a bool field using a checkbox. If a user chooses to download a recipe "IsDwnlded" is checked True, if not by default it is False. I need to create a query that would go thru my FEED_BK table, count how many times each one has been checked TRUE and return RECIPE.RecipeName...Is this possible?
    Sorry if this is confusing.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I know you said a query but you could get the result using the DCount() function. Something like:
    DCount("IsDwnlded","FEED_BK","IsDwnlded = True")
    and
    DCount("IsDwnlded","FEED_BK","IsDwnlded = False")
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    FEED_BK has multiple records associated with each recipe? If recipe is not 'downloaded' how else is it obtained by user?

    Maybe build a query that joins the two tables (just to pull in the RecipeName field). Then switch to Totals query and group by the RecipeName with aggregate expression:

    Sum(Abs([IsDownlded])) AS CountTrue
    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
    ajk825 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    15
    They could simply look at it online...by downloading it they would be adding it to their own personal libraries at home, work, wherever...

  5. #5
    ajk825 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    15
    Hi Bob,
    I tried the DCOUNT and it is returning the total number of records where "IsDwnlded = True" .. Is there any way Access can compare how many times each FEED_BK.RecipeID_FK has had FEED_BK.IsDwnlded checked? So that if say... FEED_BK.RecipeID_FK "6" has FEED_BK.IsDwnlded = "True" 21 times, and FEED_BK.RecipeID_FK "21" has FEED_BK.IsDwnlded = "True" 3 times it will return FEED_BK.RecipeID = "6"?
    I hope I'm making this clear...I apologize if not..

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Did you try my suggestion in post 3?
    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
    ajk825 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    15
    Hi June7, sorry... I don't understand what you mean by "switch to Totals query and group by the RecipeName with aggregate expression:
    Sum(Abs([IsDownlded])) AS CountTrue", so I've been looking into it. Still really new with Access and SQL...
    Here's what I have so far:
    SELECT
    RECIPE.RecipeName
    FROM
    RECIPE INNER JOIN FEED_BK
    ON RECIPE.RecipeID = FEED_BK.RecipeID_FK
    WHERE FEED_BK.IsDwnlded = True;

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    With query in design view, click Totals on the Design tab.

    Create CountTrue (or whatever you want to call it) field with expression on the field row of grid.

    The resulting sql should be like:

    SELECT
    RECIPE.RecipeName, Sum(Abs([IsDownlded])) AS CountTrue
    FROM
    RECIPE INNER JOIN FEED_BK
    ON RECIPE.RecipeID = FEED_BK.RecipeID_FK
    GROUP BY RecipeName;

    Or open in SQL View and copy/paste the above in place of your sql then switch to Design View.

    Access Help has more guidelines on using the query builder.
    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
    ajk825 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    15
    Hi June Thanks for the help I appreciate it, I did the above and was asked for a value to input for a parameter, but this isn't what I am trying to do. I want to hit the execute button and it to return the RecipeName with the most IsDwnlded = True checks. I also tried adding IsDwnlded = "True" into it in various spots and kept being asked for an input value.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Did you copy/paste the sql as suggested?

    What parameter is requested?

    Filter on IsDownlded field should not be necessary.

    If you want record(s) with highest count then add the TOP N qualifier to the query. With query in design view, click in the tables area, look at the Property Sheet for the Top Values property. Enter 1.
    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.

  11. #11
    ajk825 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    15
    Hi June7 yes I did exactly as above. It is asking for a value for IsDwnlded when i hit execute... if I type in True i get:
    This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables. (Error 3071)
    Maybe using a True/False value to mark whether or not it was downloaded was not a good idea but I didn't know how else to keep track.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I tested this expression with my data and it works. Looks like I may have misspelled IsDwnlded as IsDownlded. Use whatever is correct.
    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.

  13. #13
    ajk825 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    15
    Hi June7..I didn't even catch that. I tried it again with the correction and you did it. Thank you so very much.

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

Similar Threads

  1. Control Value Comparison
    By CementCarver in forum Programming
    Replies: 24
    Last Post: 10-14-2013, 04:48 PM
  2. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM
  3. Comparison
    By raytackettsells in forum Queries
    Replies: 2
    Last Post: 08-06-2012, 05:30 PM
  4. Comparison
    By VICTOR HUGO in forum Access
    Replies: 8
    Last Post: 02-10-2010, 04:32 PM
  5. Time Comparison
    By Larry819 in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 09:26 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