Help!, running sum on form! 
Author Message
 Help!, running sum on form!

In the tech net article " How to create a running sum on a form"
the author uses the code:

ControlSource: =DSum("[Freight]","Orders",_
                                "[OrderID] <= Forms![Form1]![OrderID]")
to sum freight charges for an order number less than or = to the
currently displayed record.

I tried DSum("[fldname1]","tblname1","[fldname2] =
Forms![Form1]![fdlname2]")
where fldname1 is the field I want summed, fldname2 is the field that I
want use as
my currently displayed field that determines the criteria for the sum.

Doesn't work.

The situation is that I have a main form and a subform. The main form
should display the Order total $ amount with a source table of tblOrders.
The subform (source table tblTransactions) allows entry of product ids,
cost per product etc. The main form's "Order total amount" needs to display
the total cost of all the items selected in the subform. It doesn't have to
update automatically if I can use a command button. The main problem here I
think is that the the field I have to use for fldname2 above is not unique.
It can't be since it is used as my order number that corresponds to item
numbers.

Any, ANY help would be appreciated! My deadline is Friday and this is all
that holds me up.

Thanks!

--
S.E. Hanley

Applications Programmer
Callaway Gardens
Pine Mtn. GA



Fri, 30 Jun 2000 03:00:00 GMT  
 Help!, running sum on form!



Quote:
>In the tech net article " How to create a running sum on a form"
>the author uses the code:

>ControlSource: =DSum("[Freight]","Orders",_
>                                "[OrderID] <= Forms![Form1]![OrderID]")
>to sum freight charges for an order number less than or = to the
>currently displayed record.

>I tried DSum("[fldname1]","tblname1","[fldname2] =
>Forms![Form1]![fdlname2]")
>where fldname1 is the field I want summed, fldname2 is the field that I
>want use as
>my currently displayed field that determines the criteria for the sum.

>Doesn't work.

S.E.

The general code described in the technet cd does work.  You don't describe
what doesn't work when you place it in the control, so its hard to help
exactly.  I am assuming that what you mean by fldname 2 is not unique, is
that the order number in tblname1 is not unique because it is duplicated for
each item in the order; this shouldn't be a problem.  To auto calc the value
on the mainform, you should put the code in the afterupdate event of the
subform; something like Me.Parent!MyOrderSumControl = DSum(etc.) this would
force a recalc for each updated record in the subform.

HTH

Steve Arbaugh
ATTAC Consulting Group
web: http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm
To reply, remove ~ and nospm from address



Fri, 30 Jun 2000 03:00:00 GMT  
 Help!, running sum on form!

The easiest way round this is to use the subform's footer. In here place a
textbox with its control source as
=Sum([FieldToSum])
Name the field as something like InvoiceSubTotal and make the subform
footer visible property No.

On the Main form add another text box and set its control source as
=[SubformName].Form![InvoiceSubTotal]

The total on the subform will calculate automatically as you change
information as will the field on the main form.

Hope this helps

Terry



Quote:
> In the tech net article " How to create a running sum on a form"
> the author uses the code:

> ControlSource: =DSum("[Freight]","Orders",_
>                                 "[OrderID] <= Forms![Form1]![OrderID]")
> to sum freight charges for an order number less than or = to the
> currently displayed record.

> I tried DSum("[fldname1]","tblname1","[fldname2] =
> Forms![Form1]![fdlname2]")
> where fldname1 is the field I want summed, fldname2 is the field that I
> want use as
> my currently displayed field that determines the criteria for the sum.

> Doesn't work.

> The situation is that I have a main form and a subform. The main form
> should display the Order total $ amount with a source table of tblOrders.
> The subform (source table tblTransactions) allows entry of product ids,
> cost per product etc. The main form's "Order total amount" needs to
display
> the total cost of all the items selected in the subform. It doesn't have
to
> update automatically if I can use a command button. The main problem here
I
> think is that the the field I have to use for fldname2 above is not
unique.
> It can't be since it is used as my order number that corresponds to item
> numbers.

> Any, ANY help would be appreciated! My deadline is Friday and this is all
> that holds me up.

> Thanks!

> --
> S.E. Hanley

> Applications Programmer
> Callaway Gardens
> Pine Mtn. GA



Sat, 01 Jul 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Running sums on a FORM??

2. Running Sums in Forms

3. Article: How to create a running sum on a form

4. How to do a Running Sum with Only Negatives

5. Running sum

6. Running sum question again

7. How to Count with Running Sum

8. Running Sums with queries

9. AM I missing something - Sum and Cumulative Sum

10. Running Sum

11. Creating a running sum query

12. running sum

 

 
Powered by phpBB® Forum Software