Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Total In Continuous Form 2

Status
Not open for further replies.

philcon

Technical User
Feb 5, 2002
139
GB
Hi all,

I was just wondering whether its possible to have a control in the detail of a continuous form which keeps a running total of another field

I would imagine not but would appreciate anyones help.

Regards


Phil.
 
Yep you can (stop being so negative :) )

Detail - if this includes the footer
Put one in the "footer" part of the subform.

In your controls "data" section use it as you would on a report ie =Sum([TotalAmount]) (if TotalAmount is in the main part etc etc)

If not create a column in the table that will hold the running total and store the running total in it as you go.
As you add a newLine amount lookup the last totalAmount, add the newLine amount and store it in the new totalAmount.
AS long as a control is linked to a table you can put in, change it as you will.
 
Ian,

I do wnat a total for the form, I need a running total.

If I put the control = sum([etc]) in the detail section then I just end up with the total for the form.

The form is based on a select query not a table so I how would I build the running total within that framework?

Sorry its possible I didnt understand your reply

Regards

Phil.
 
Hi Phil;

OK Firstly a query is just a selection that comes from a table/s. The table is what you should be looking at.
Somehow you need to be able the place another column in the table (it needs to be updateable). This is the place that holds the running total. This will allow diferent totals in your form.

Now for the hard bit. (Of course there may be other way to do this)
Know how to code?
After Update (of the subform [qty] or whatever) Create a recordset also based on the same query.
Loop through the rec/set to find the runtotal so far and add it to your new total and save it in the running total column.

Good luck Ian
 
Hi, I've got the following saved for running sums in continuous forms:

SELECT Table1.asd, DSum(&quot;[asd]&quot;,&quot;table1&quot;,&quot;[AN]<=&quot; & [AN]) AS RunningSum
FROM Table1;

Your table needs an incrementing number, like an autonumber field for this to work. Create a table - Table1. Create one field -ASD & make it Numeric.
Create another field - AN & Make it an autonumber.

Enter a few numbers into the ASD field.

Create a query in design view. Select: View - SQL View and paste the select statement above into it. The results should be what you're looking for.

Hope that helps.
 
Thanks guys, will try both and get back to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top