Running Sum in a Form

  • Thread starter mroks via AccessMonster.com
  • Start date
M

mroks via AccessMonster.com

i have continuous form and i want to have a running sum on it just like on
the report. Your help is very much appreciated.

thanks.
 
M

M Skabialka

Add a footer to your form, and create a control with the total similar to
what you would do in a report e.g.
=Sum([InvoiceAmount])
Call the Control something other than your original field name, so e.g.
SumOfInvoiceAmount

Mich
 
M

mroks via AccessMonster.com

Mich,
I got your point, but this will not answer my query. Please see my
illustration below

Note: This is a continuos Form
1 ballpen 5.50
2 paper 1.00
3 bond paper 0.50
4 pencil 4.00

the number 1-4 is the running sum

thanks,


M said:
Add a footer to your form, and create a control with the total similar to
what you would do in a report e.g.
=Sum([InvoiceAmount])
Call the Control something other than your original field name, so e.g.
SumOfInvoiceAmount

Mich
i have continuous form and i want to have a running sum on it just like on
the report. Your help is very much appreciated.

thanks.
 
K

krissco

Mich,
I got your point, but this will not answer my query. Please see my
illustration below

Note: This is a continuos Form
1 ballpen 5.50
2 paper 1.00
3 bond paper 0.50
4 pencil 4.00

the number 1-4 is the running sum

Well, here is a poor solution you can play with:

Create the following function in a standard module:
Public Function myRunSum(strGarbage As String) As Integer
Static intSum As Integer
intSum = intSum + 1
myRunSum = intSum
End Function

Add the following field to the record source of your form:
myRunSum(somefieldnamegoeshere) as myRun

Bind myRun to a control.

Ok. So what's the deal with this solution? It is pretty crappy (as you
will see if you open and close your form several times). You need the
strGarbage parameter - otherwise Access is "smart" and will run your
function only once, not once for each row.

Try throwing an optional boolean parameter in the function like
"blReset". Then call the function w/ blReset = true during onload/
onopen or something like that. Change the function to reset when
blReset = true.

Well, that should give you enough to play with. Have fun!

-Kris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top