Results 1 to 9 of 9
  1. #1
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162

    Sum of Subform from a Query



    Hi Guys I have this form below. As you can see there are Prepayments and Accruals

    I need to add the amounts together based on its Description, i Set up a query so that it SumS by group

    =[AccrualPreyments]![SumOfAmount]

    But this doesnt work comes back as Name? Any Ideas
    Site No Description Comments Group Code Expense Code Amount
    0272S Prepayments
    A 92 454.85
    0272S Prepayments
    A 92 -454.85
    0272S Prepayments
    A 87 139.85
    0272S Prepayments
    A 87 -122.84
    0272S Accrual
    A 55 -650.00
    0272S Accrual
    A 55 1293.00
    0272S Accrual
    A 64 1870.35
    0272S Accrual
    B 65 78.82
    0272S Accrual
    B 82 -16530.57
    0272S Accrual
    B 82 8652.94
    0272S Accrual
    B 82 455.77
    0272S Accrual
    B 82 5478.5
    0272S Accrual




  2. #2
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30
    Yes. It looks like a misspelling of "AccrualPreyments"

  3. #3
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    spelling is correct so far as program is concerned (actual spelling not so much)

  4. #4
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30
    OK, so your form is named "AccrualPreyments". The Prepayments and Accruals show in the detail section of the report. What is "SumOfAmount"? Is that a control on the form where you want the total to show up? Is that in the footer?

  5. #5
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    I created a query to group 'Site Number' 'Amount' by Description

    So the query returns:-

    Prepayments £11.07
    Accruals £-2452.36

    Now i need these to display on the form (outside the subform)

    As i cant figure a way of Suming withing subform (at the footer) to sum @Prepayments = x

    If you know what i mean

  6. #6
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30

    Thumbs up

    Keiath,

    So do you want the sum in the footer of the subform or on the main form?

    You can do it in the footer of the subform.
    Open the subform in design view.
    Create a text box control in the footer.
    For the Control Source of that box, enter this:
    Code:
    =DSum("[Amount]","NameOfSourceForSubform","[Description]=Prepayments")
    Of course, you will need to provide the name of the table or query that is the source for the form. You can also Provide the Caption for the Label for this text box as something like "Sum of Prepayments:"

    Then do the same for the accruals.

    You can also do this on the main form, if you like, but it sounds like that is your second choice.

    HTH
    _________________
    Regards,
    Marvin M
    Windows 7 Professional, MS Access 2007/2010
    Windows 8 Professional, MS Access 2013
    -------------------------------------------------------------------------------------------------------------------
    If this post has helped you, please click on the little sheriff badge in the lower left corner. Thanks!
    -------------------------------------------------------------------------------------------------------------------

  7. #7
    keiath is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    162
    I tried this

    =DSum("[Amount]"," [AccrualsPreyments]","[Description]=Prepayments")

    In the footer of the subform

    Then

    =[Accruals subform].[Form]![Text14]

    Outside the subform

    but no luck

  8. #8
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30
    OK. In the DSum function,
    DSum("[Amount]"," [AccrualsPreyments]","[Description]=Prepayments")

    [Amount] is the name of the field that you want to sum.
    [AccrualsPreyments] is the name of the source table to your subfrom.
    [Description] is the name of the field that has the condition in it.

    Is that correct? Let's try it with no spaces between the quotation marks. Like this: "AccrualsPreyments"
    No spaces inside the quotes.
    Does that give you a result in the footer of the subform?

  9. #9
    MarvinM's Avatar
    MarvinM is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    30
    Then on the main form (Outside the subform), you want to show that value again?
    You have an unbound text box with this as the Control Source:
    =[Accruals subform].[Form]![Text14]

    Try the full format like this:
    [Forms]![MainFormName].[Form]![NameOfSubformControl].Text14

    Note that the object after "Form!" is the name of the control, or the container that holds your subform, and NOT the name of the subform. This assumes that Text14 is the name of the control on your subform in which you have your DSum formula.

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

Similar Threads

  1. Replies: 18
    Last Post: 02-14-2014, 05:06 PM
  2. sent subform data to query
    By mathanraj76 in forum Programming
    Replies: 1
    Last Post: 05-30-2013, 11:35 PM
  3. Update query subform
    By putte11 in forum Forms
    Replies: 10
    Last Post: 11-28-2012, 12:16 PM
  4. Replies: 5
    Last Post: 05-11-2011, 07:32 PM
  5. Query results in subform
    By MWMike in forum Forms
    Replies: 5
    Last Post: 09-28-2010, 05:19 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