Results 1 to 7 of 7
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    Best way to sum totals at bottom of form


    I have a continuous form with a header section and then detail section. I would like to get a total count and sum for a particular field in the detail section and have it show in the header section.

    In this case I have detail records for several cars. Each car has what is called a rider and each car has a revenue. There will be multiple cars on one rider. So I might have 100 cars on 5 different riders each with a revenue.

    I am looking for the best way so sum that up, if possible, without a query. I need it to show the total number of cars per rider and the total revenue per rider.

    Is this something that can be done with a dcount?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,024
    Probably, using riderID as the criteria ?
    Same with DSum()
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Dcount is usually done on a table. I want to do more like a report but on a form. For all the line items showing in the current detail area count all the unique rider numbers.

    On a report I would do this by grouping and sorting, not sure how to do it on a form.

    The way I do it with a basic sum is in the page footer of the detail subform i put =Sum([CRevfromCustomer]) Then in the parent form I put =Nz([f_Invoicing_Detail].[Form]![SumOfRev]). This allows me to sum the total on the subform, then pass it to the parent form. Sum is easy though because it just adds everything. I need to to say how many of each rider there is. For example

    Rider count
    1 7
    2.2 15
    7 22

    something like that , and then with the revenue
    Rider Total Revenue
    1 $500.00
    2.2 $2500.00
    7 $3500.00

  4. #4
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Just put a textbox in your header (or footer) and set the control source to =Sum([field_you_want_to_sum])
    You can do the same four count... =Count([field_you_want_to_count])

    Beware: These will sum/count the fields currently filtered on the form, if the user is able to apply/change a filter then the records that are filtered out will be excluded from the sum/count. This may or may not be desirable.

  5. #5
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    I already have that, the problem is that it is not counting the unique riders. Every customer has a different number of riders with different rider numbers so doing count just counts everything and doesnt give me how many riders of each number they have.

  6. #6
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Unfortunately it sounds like you will need a second subform.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,827
    This sounds like a job for a report given that it has the ability to create groups as well as do calculations (counts & running sums especially) over groups. Forms are more for inputs and less so reporting - especially over groups.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-22-2018, 08:18 PM
  2. Replies: 1
    Last Post: 04-21-2015, 07:39 AM
  3. How to display totals at bottom of query or report
    By Access_Novice in forum Access
    Replies: 1
    Last Post: 09-12-2014, 12:58 AM
  4. Totals showing across bottom of Datasheet view
    By Laurie B. in forum Access
    Replies: 8
    Last Post: 09-14-2011, 01:47 PM
  5. can't update form-in the bottom bar of
    By ymds in forum Access
    Replies: 2
    Last Post: 07-19-2010, 06:26 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