Sum the column in a subdatasheet.

Posted on 2004-11-05
Last Modified: 2012-08-14
I have a subdatasheet in a form. It is  for parts used on an invoice.

Qty    PN     Desc      Unit cost      Amount     Discount      Total

Amount is = [Qty]*[Unit Cost]

Total is = [Amount]*[Discount]

There may be 5 or so parts that are used on an invoice.

So there would be 5 values in the total column.

How do I get the sum of these totals no matter how many rows there are?

Any help would be greatly appreciated...

Question by:Basicfarmer
    LVL 8

    Expert Comment

    On the sub datasheet footer create a control with the formula

    =Sum([Qty]*[Unit Cost])

    and another with the formula

    = Sum([Amount]*[Discount])

    Placing the control in the footer section will sum all the records in the detail section
    LVL 1

    Accepted Solution

    SashP is showing you how to calculate the info you need (needs to be in the footer), but I don't think the footer can be visible on a datasheet form.  So do your calculations that way .... then the next step would be to carry the info out to your main form.

    Using the two samples above from SashP, lets say you created them and their names are "YourSumAmount" and "YourSumTotal"..... create a new control on your "main" form with the following:

    This will give you the values from the subform footer in some controls on your mainform (so you can move them around) ... or use to code to update other fields on the main form or whatever else you might want.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now