ACC2000: How to Use DSum to Create a Running Sum on a FormID: Q210495
|
Reports have a RunningSum property; forms do not. This article shows you how to create a running sum on a form.
To create a running sum on a form, the underlying table or query must have
a unique, sequential, ID field, such as an AutoNumber or a Date/Time timestamp field. If your table does not have such a field, you can open the table in Design view and add a new field to create one.
NOTE: The following example uses the DSum() function to generate a running sum on a form. For additional information about how to obtain this sample file, please see the following article in the Microsoft Knowledge Base:
Q210338 ACC2000: Sample Function to Create a Running Sum on a FormThe following example uses the sample database Northwind.mdb to show you how to create a text box on a form that sums the freight amount for the current customer order and all preceding customer orders:
Form: Form1
--------------------
RecordSource: Orders
Text Box: Order ID
ControlSource: OrderID
Text Box: Total
ControlSource: =DSum("[Freight]","Orders",_
"[OrderID] <= Forms![Form1]![OrderID]")
The DSum() function calculates the sum of all freight charges on orders with an Order number less than or equal to the currently displayed order number. For this reason, it is important to have a unique and sequential ID field.Additional query words: inf subtotal query
Keywords : kbdta FmsHowto
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 13, 1999