Results 1 to 13 of 13
  1. #1
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27

    Sum Function Driving me to the brink!


    Hi. Good Day to you all.
    Can someone please help me understand what variable is making this simple Sum Function not work on this Subform. The Field SubTotal is calculated in the Query. It is formatted as Currency. It returns #Error. I have this method working on other SubForms but this one will simply not Playball. I can't seem to track down any rhyme or reason to it.
    Click image for larger version. 

Name:	SumFunciton.jpg 
Views:	20 
Size:	57.1 KB 
ID:	49707

    Last edited by JonoGee; 02-16-2023 at 03:34 AM. Reason: Image did not display

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    Please show us the query SQL and what you have set the control source to on the the sub form.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    SELECT tblQuotationNonSKUs.QuotationNonSKUsID, tblQuotationNonSKUs.QuotationNumberID, tblQuotationNonSKUs.LineDescription, tblQuotationNonSKUs.Qty, tblQuotationNonSKUs.UOMID, tblQuotationNonSKUs.GrossMarginPercent, tblQuotationNonSKUs.SalePriceGBP, tblQuotationNonSKUs.LineTaxGBP, tblQuotationNonSKUs.TaxRateID, tblQuotationNonSKUs.LineNotes1, tblQuotationNonSKUs.LineNotes2, tblQuotationNonSKUs.LineNotes3, tblQuotationNonSKUs.CostPrice, tblQuotationNonSKUs.DiscountPercent, tblQuotationNonSKUs.DiscountGBP, tblTaxRate.TaxRate, [Qty]*[SalePriceGBP] AS SubTotal, IIf([DiscountPercent] Is Not Null,[SubTotal]*[DiscountPercent],IIf([DiscountGBP] Is Not Null,[DiscountGBP],0)) AS [Total Discount], ([SubTotal]-[Total Discount]) AS [Total Ex Tax], [Total Ex Tax]*[TaxRate] AS [Total Tax], [Total Ex Tax]+[Total Tax] AS [Total Inc Tax] FROM tblQuotationNonSKUs LEFT JOIN tblTaxRate ON tblQuotationNonSKUs.TaxRateID = tblTaxRate.TaxRateID;
    Click image for larger version. 

Name:	SumFunciton2.jpg 
Views:	20 
Size:	65.9 KB 
ID:	49708

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    Okay - if you run that query from the query editor, I assume you get sensible results?
    If you do - what is the control source for the form where it is displaying #Error?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    Yeah the query runs fine and calculates and display all the data as expected fromthe query editor..
    I am not sure what it is you want me to show you when you reference the control source? Do you want to see the table design that this SubForm references?

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    On the form where it says #Error - in design mode what is the control source for that textbox.

    I thought the query was the record source for the subform?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    The query is the record source for the SubForm.
    Click image for larger version. 

Name:	SumFunciton3.jpg 
Views:	19 
Size:	32.1 KB 
ID:	49709
    The control source is just the Sum formular referencing the created field in the query called [SubTotal]

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    It might be because the Subtotal is already a calculated summed field in the underlying query.

    Try creating another query that uses the original query as it's source, just bring in all the fields, and save it.
    Use that as the basis for the sub form and see if it makes any difference.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    The SubTotal is Calculated field in the underlying Query. The Sum of SubTotal that is not working is suppose to be summing up the SubTotal from multiples records in the continuous subform. Does that make sense? I will try your suggestion and see if I get any joy.. Theres clearly something interferring with it but I can't figure out for the life of me whats wrong

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,939
    what is the name of your subtotal control in the detail section?

  11. #11
    JonoGee is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2022
    Posts
    27
    It is just 'SubTotal' as defined manually in the query..
    Click image for larger version. 

Name:	SumFunciton4.jpg 
Views:	18 
Size:	33.3 KB 
ID:	49710

    Click image for larger version. 

Name:	SumFunciton5.jpg 
Views:	18 
Size:	17.5 KB 
ID:	49711

  12. #12
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,939
    a few thoughts

    1. change the name of the control from subTotal to txtSubotal or similar to avoid confusion with the name

    2. appreciate the subtotal value should be numeric - but is it? suggest modify your query to cCur([Qty]*[SalePriceGBP])

    3. do you have some errors in you calculation due to missing data?

  13. #13
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,822
    You could also try:-
    Sub Total:Nz([Qty],0)*Nz([SalePriceGBP],0)

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

Similar Threads

  1. DLookup driving me mad
    By KieranJ2020 in forum Programming
    Replies: 7
    Last Post: 10-11-2022, 09:31 AM
  2. this is driving me nuts
    By Raleyoz in forum Access
    Replies: 20
    Last Post: 06-02-2015, 08:10 AM
  3. Parameters driving me mad
    By reburton in forum Programming
    Replies: 14
    Last Post: 10-31-2013, 01:35 PM
  4. ShipToCode is driving me crazy
    By Accessgrasshopper in forum Access
    Replies: 7
    Last Post: 02-26-2011, 04:55 PM
  5. Pls help... driving me insane!
    By Maverick1501 in forum Reports
    Replies: 1
    Last Post: 03-31-2010, 06:26 AM

Tags for this Thread

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