473,788 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running Sum

1 New Member
I have searched for an answer but have failed to come up with anything that seems to work.

I am trying to set up an Access 2003 database for home accounts. I want to create a running sum (a balance based on what has been spent or paid in).

I have a table called tblCardBankPymn ts. In that I have a Figure column for what transaction has been done. I also have a Balance column but think I should not have this now.

I then have a form to fill this in and I think it is on this form I need to have the Running Sum in the Balance text box.

I came across the following VBA code and added the following into a new module called modRunSum:

Expand|Select|Wrap|Line Numbers
  1.  Option Explicit 
  2. Public Function frmRunSum(curForm As Form, idName As String, _
  3. idValue, sumField As String)
  4. '***********************************************************
  5. '* curForm - Always 'Me' for easy setting of form object. *
  6. '* idName - Unique fieldname (usually primarykey). *
  7. '* idValue - Value of idName. *
  8. '* sumField - The name of the field to runsum *
  9. '***********************************************************
  10. Dim rst As DAO.Recordset, subSum
  11.  
  12. Set rst = curForm.RecordsetClone
  13.  
  14. 'Find the current record via proper syntax for Data Type.
  15. Select Case rst.Fields(idName).Type
  16. Case dbLong, dbInteger, dbCurrency, _
  17. dbSingle, dbDouble, dbByte 'Numeric Data Type
  18. rst.FindFirst "[" & idName & "] = " & idValue
  19. Case dbDate 'Date Data Type
  20. rst.FindFirst "[" & idName & "] = #" & idValue & "#"
  21. Case dbText 'Text Data Type
  22. rst.FindFirst "[" & idName & "] = '" & idValue & "'"
  23. Case Else
  24. rst.MovePrevious 'Set BOF!
  25. End Select
  26.  
  27. 'Running Sum (subTotal) for each record occurs here.
  28. Do Until rst.BOF
  29. subSum = subSum + Nz(rst(sumField), 0)
  30. rst.MovePrevious
  31. Loop
  32.  
  33. frmRunSum = subSum
  34.  
  35. Set rst = Nothing
  36.  
  37. End Function
  38.  
I then added the following into the Form_frmCardBan kPymnts Class Object in the VBA window:

Expand|Select|Wrap|Line Numbers
  1.  Public Function frmCardBankPymnts() 
  2.  
  3. '*******************************************************************
  4. '* idName - Unique field name. *
  5. '* sumField - The name of the field to runsum *
  6. '*******************************************************************
  7.  
  8. If Not IsNull(Me!Balance) Then 'Skip New Record!
  9. frmCardBankPymnts = frmRunSum(Me, "Balance", Me!Balance, "Figure")
  10. End If
  11.  
  12. End Function
  13.  
On the frmCardBankPymn ts form (used to enter the data into the tblCardBankPymn ts table) in the Balance textbox Control Source box I then have: =frmCardBankPym nts()

I have a start figure in row one of the tblCardBankPymn ts in the Figure column of 100 pounds and then in the next row a figure of 50 pounds. Yet, on the form it displays 100 pounds in each of the rows, not 150 as I would have expected.

Can anyone help please? I see in Access 2007 there is a Running Sum funtion, but in Access 2003 this does not exist.

Many thanks

Brian Miller
Jul 13 '07 #1
1 2762
AdrianJ1980
13 New Member
It's easy to do in a report through the properties menu as per http://office.microsoft.com/en-us/ac...873881033.aspx
Dec 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
6937
by: Ross Presser | last post by:
OK, I've been researching this problem and can't find a definitive answer yet. The situation is one that seems to have come up a few times to different folks. I am writing an application that will function as a windows service and will also present a GUI to the user. I don't want "Interact with desktop"; I want the same exe to run as a normal non-interactive service when started properly by the service control manager, or instead to run...
4
10360
by: Bill Dika | last post by:
Hi I am trying to calculate a running total of a calculated textbox (tbAtStandard) in GroupFooter1 for placement in a textbox (tbTotalAtStandard) on my report in Groupfooter0. The problem that I am having is that sometimes the correct total shows up in print preview and sometimes it doesn't. Sometimes it is higher and sometimes it is lower (than the correct amount) and I cannot make any sense of the difference. The difference...
1
5786
by: Ennio-Sr | last post by:
Hi all! Testing a script where I need to make sure that postgresql is running before passing a <psql dbasename -c "insert into ..." > instruction I faced this curious behaviour: This is the relevant content of the script: ------------------ #!/bin/bash /usr/lib/postgresql/bin/pg_ctl status -D /var/lib/postgres/data >/dev/null 2>&1 rtn=$?
1
6025
by: Anonieko | last post by:
Query: How to display progress bar for long running page Answer: Yet another solution. REFERENCE: http://www.eggheadcafe.com/articles/20050108.asp My only regret is that when click the browser back button, it loads the progress bar again. Any solution to this?
7
1804
by: pradeep_TP | last post by:
hello all, I want to know how can I check whether a web site us running or not. I have used HttpWebRequest but when I give a web site address, It takes few number of seconds to throw exception if the web site is not running. Is there any easy method of doing the same. I do *not* want to use IP to ping and check the server. Thanks pradeep_tp
3
1571
by: Anil Kumar Sharma | last post by:
Hello, I am working on C# using vs.net 2003. I have faced two interesting problems. 1. Dynamically setting Default Button: I created a form and used it in various contexts. On basis of the context, the panel of a form which contains various buttons , are shown or hides. Now at design time i set the default button property to one of button. But when the form object is created in different context and set visibilty of default
4
4185
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
16
11321
by: Gandalf186 | last post by:
I need to create a query that produces running totals for every group within my table for example i wish to see: - Group A 1 5 9 15 Group B
2
4645
by: upperclass | last post by:
Hi, I'm trying to find a decent way to measure program running time. I know clock() is probably the standard way of doing it but clock_t overflows too quickly. The target program running time ranges from a few seconds to a day. Is there a decent+portable way to deal with this? Thank you.
1
8145
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings file and itself into the exe. You would probably want a tool for this bit which could be in the zip too. So the app isnt single exe when running but when not running, it is. Just an idea for you to think about. Another option would possibly be to...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.