Results 1 to 5 of 5
  1. #1
    Zetheroth is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Jun 2022
    Posts
    31

    Question sums too many items, need to sum the distinct values for each field in acres


    Firstly, cant figure out why it requests me to put an input in when its directly linked to the combo boxes on the main menu. But the second thing I need to figure out is how to sum the acres for my tons/acre just once for each field, because a field might have 3 inputs but doesnt mean you should count the acres 3 times. You all have always been helpful in learning how to properly format these things, as well as showing how to fix my issues, so I'm looking forward to any input on either issue, as well as the database as a whole.Sales Test.zip

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    You're getting large horse pasture 3 times because it's in the production table 3 times. It needs to be in one record showing 3 tons.
    You're probably getting prompts for input because the Main Form is not loaded (or is loaded in design view) when you run the report manually.

    Click image for larger version. 

Name:	three.png 
Views:	26 
Size:	31.1 KB 
ID:	49657

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Large Horse Pasture is actually in table 4 times, not just 3. Were these cuts all on same date - if so, why not a single entry? Should there be a DateCut field in TBLProduction?

    Query and report open just fine when the form is already open. I don't use parameterized queries. I prefer VBA to build filter criteria and apply to form or report. Checkboxes do not have True or False value when form opens. Should not need two Both checkboxes. Put 3 checkboxes (or radio buttons) in an OptionGroup so only one can be selected then use value of OptionGroup to build criteria. Actually, 4 checkboxes or radio buttons - Watered, Fertilized, Both, All (values of 0, 1, 2, 3). Consider:

    WHERE (((TBLFields.Watered) LIKE IIf(Forms![Main Menu]!opt1 IN (0,2),True,"*")) And ((TBLFields.Fertilized) LIKE IIf(Forms![Main Menu]!opt1 IN(1,2),True,"*")));

    Referencing checkboxes in query is tricky. Suggest you review http://allenbrowne.com/NoYesNo.html

    Build aggregate query on TBLProduction then build another query that joins aggregate query to TBLFields. But if you want to see TBLProduction details, then this will not serve and report needs redesign. If you want summation by Field, then why do you have Hay header instead of Field header?

    If you want tons per acre, shouldn't you divide acres by sum(tons)? Calculation in Field Name header: ="tons per acre: " & Round([acres]/Sum([tons]),2).
    If you really want acres per ton, then reverse the calc.

    Don't need = sign in =[acres], just the field reference.
    Last edited by June7; 02-09-2023 at 07:20 PM.
    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
    Zetheroth is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Jun 2022
    Posts
    31
    there should and eventually will be a datecut field, if the query worked for both of you that's great, I was having issues even with the main menu open and checkboxes selected, so I'm curious about the other options, i basically need a watered, fertilized, both, and neither but am quite new to access. After a review I believe a combo box might be the simplest solution. There will be 2 reports eventually, one for by the field, and the other for by the hay type. It is most defiantly not displaying acres per ton or that number would be considerably larger, the issue I'm having is even though I have multiple lists of the same field (large horse pasture) I need to only add its acres to the sum one time.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    See if this revision gets you close.
    Attached Files Attached Files
    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. Replies: 1
    Last Post: 06-01-2017, 09:29 AM
  2. Replies: 4
    Last Post: 12-29-2016, 03:07 PM
  3. Replies: 3
    Last Post: 10-30-2016, 05:50 AM
  4. Memo Field Cut Off - But Need Distinct Values
    By accessnewbie352 in forum Reports
    Replies: 1
    Last Post: 01-16-2015, 01:00 PM
  5. Replies: 0
    Last Post: 02-28-2010, 08:35 AM

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