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!

How to sum a child grid column 3

Status
Not open for further replies.

vitorsa

Programmer
Apr 28, 2000
13
PT
I want to show the totals of a child grid just above it.
 
Simply SUM the controlsource of the column in question and display the result in a textbox or the like.

Jim
 
Since the table involved is a child you'll probably want to do something like:

SUM FOR childID = ParentID TO result

Jim
 
Hi Vitorsa,
Create a text box 'myTotal' for the purpose of displaying the total...

Add the code...
myTotal.RefreshEvent
********************************
LOCAL lcAlias, lnRec, lnTotal
lcAlias = ALIAS()
lnTotal = 0
lnRec = 0
SELECT myChildDBF
IF ! EOF()
lnRec = RECNO()
ENDIF
IF lnRec > 0
** replace myField with your field name
SUM(myField) TO lnTotal
GO lnRec
ENDIF
This.Value = ALLTRIM(TRANSFORM(lnTotal,"99,999,999.99"))
SELECT (lcAlias)
This.Enabled = .f.
********************************

Add the following code in the
myChildGrid.AfterRowColChangeEvent
**********************************
ThisForm.myTotal.Refresh()

This will fix your requirement.
Best of luck ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top