Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 22nd, 2006, 12:43 PM
Registered User
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to timdasa Send a message via Yahoo to timdasa
Default Help: Running Sum (or Cumulative Sum)

I am writing a program in VB6 with ms Access database, and I use VB6 Report designer (without data environment). I need help on how to calculate cumulative sum (or running sum) of a field in the table for each record, and display the resulting sum as a column in the report.

supplierName DateofSupply AmountSupplied
ABC PLC 10/11/2004 2000
Delight Inc. 04/02/2005 5000
Kings International 06/02/2005 1000
Logic Systems 09/02/2005 1500
Horizons Intl 16/02/2005 3000

The intended result should be as shown below:
supplierName DateofSupply AmountSupplied CumulativeSupply
ABC PLC 10/11/2004 2000 2000
Delight Inc. 04/02/2005 5000 6500
Kings International 06/02/2005 1000 7500
Logic Systems 09/02/2005 1500 9000
Horizons Intl 16/02/2005 3000 12000

Please can someone help me out with the code or a sample that does this task.
Thanks in advance.

Old August 22nd, 2006, 03:12 PM
Friend of Wrox
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

In the OnFormat event of the report add the current record's value to a module-scope tallying variable, and then set the value of an unbound control to the new value.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with a Running Sum MArgente Access 1 June 11th, 2007 06:45 AM
Running Sum in Subform Odeh Naber Access 2 May 14th, 2007 06:45 AM
"almost" a running sum I guess RobCarter SQL Server 2000 8 March 16th, 2007 02:00 AM
How to get Cumulative Sum of a Field badsy Crystal Reports 1 January 20th, 2006 05:09 PM
Running Sum semooth Access 2 July 21st, 2004 09:17 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.