MS Access how to SUM a Form with Subform?

Anonymous
2021-10-20T06:31:09+00:00

Hi,

I have two tables: CustomerTable and SalesInvoiceTable where I created a Form (CustomerTable) and Subform (SalesInvoiceTable).

I would like to see the SUM of the SalesInvoiceAmount per Customer. Keep getting error.

Microsoft 365 and Office | Access | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. HansV 462.4K Reputation points MVP Volunteer Moderator
    2021-10-20T07:38:14+00:00

    Create a text box named txtSum in the header or footer of the subform.

    Set the Control Source of this text box to =Sum([SalesInvoiceAmount]) and set its Visible property to No.

    Create a text box named txtSum on the main form.

    Set its Control Source to =[SubformName]![txtSum] where SubformName is the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the navigation pane. Click once on the subform in the main form and check the Name property on the Other tab of the Property Sheet. This is the name to use.

    8 people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. ScottGem 68,780 Reputation points Volunteer Moderator
    2021-10-20T16:42:02+00:00

    To explain the answer, you have put the sum control in the MAIN form. But the Controlsource is:

    SUM(SalesInvoiceAmount). But the Mainform doesn't know what SalesInvoiceAmount is sinced its on the subform. That's why you have to do the sum in the Subform, then reference it on the main form.

    5 people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2021-10-20T11:01:41+00:00

    Alternatively, use a Continuous Forms view subform and sum the SalesInvoiceAmount column in the subform's footer.  For an example see DatabaseBasics.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    In this little demo file the section on 'entering data via a form/subforms' includes a simple orders form in which the total of all items per order is summed in a subform's footer.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful