Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculation in grid AfterRowColChange event
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00696537
Message ID:
00696704
Vues:
11
I guess there are some typos in your formula. It doesn't match with the examples.

Anyways, I created a test form to demonstrate this.

1. In the Load() event of the form, put this code. You can USE your table two times if you don't want to create these cursors.
SET TALK OFF

CREATE CURSOR C1 (cA N(5),cB N(5))
INSERT INTO C1 VALUES (1,100)
INSERT INTO C1 VALUES (2,50)
INSERT INTO C1 VALUES (3,200)
INSERT INTO C1 VALUES (4,10)


CREATE CURSOR C2 (cA N(5),cB N(5))
INSERT INTO C2 VALUES (1,100)
INSERT INTO C2 VALUES (2,50)
INSERT INTO C2 VALUES (3,200)
INSERT INTO C2 VALUES (4,10)
2. Create new form method and call it Calculate.

3. Drop a Grid on the form with 3 Columns. Last Column should have Thisform.Calculate() as Controlsource.

4. Put the following code into Calculate method.
LPARAMETERS tnRecNo

LOCAL lnRecNo,lnRtnValue

lnRtnValue = 0
lnRecNo    = RECNO("c1") - 1

IF lnRecNo >= 1
	SELECT C2
	SUM C2.cB FOR RECNO() <= lnRecNo TO lnRtnValue
	lnRtnValue = lnRtnValue + C1.cB
ELSE
	lnRtnValue = C1.cB
ENDIF

SELECT C1
RETURN lnRtnValue
5. Run the form and it should display cumulative sum in the last column of the grid.

>Hi All,
>i have workbook on MSexcel like under
>
> A B
> produced cumulativeproduced
>1 100 100
>2 50 150 && formula B1+A2
>3 200 350 && formula B2+A3
>..
>..
>..
>
>i wantto this calculation in grid how can i do this ?
>
>Thanks,
- Jayesh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform