Mehram
asked on
VB 6 DataGrid Control
Sir, I have one control on my form namely Datagrid. A on column of this grid is amount also have one label for showing user sum of amount which they have put in grid:
Example:
First time user enter in amount 1000 then label will be show 1000
Second time user enter in amount 500 the label will automatically change on update datagrid and show 1500
Please help.
Rgds.
Mehram
Example:
First time user enter in amount 1000 then label will be show 1000
Second time user enter in amount 500 the label will automatically change on update datagrid and show 1500
Please help.
Rgds.
Mehram
You can also do the same with the recordset object.. In the aftercolupdate event of the
datagrid.. just loop the recordset and sumup the amount field and display in the label
Good Luck
datagrid.. just loop the recordset and sumup the amount field and display in the label
Good Luck
ASKER
Sir I am using following code :
Private Sub DG_AfterColUpdate(ByVal ColIndex As Integer)
Dim x%, i%
x = 0
If ColIndex = Dg.ColIndex(2) Then
For i = 0 To Dg.ApproxCount - 1
Dg.Row = i
x = x + Val(DataGrid1.Columns(2).T ext)
Next
SkinLabel19.Caption = x
End Sub
neither it is not showing any thing on skinglabel19 nor showing any error
Private Sub DG_AfterColUpdate(ByVal ColIndex As Integer)
Dim x%, i%
x = 0
If ColIndex = Dg.ColIndex(2) Then
For i = 0 To Dg.ApproxCount - 1
Dg.Row = i
x = x + Val(DataGrid1.Columns(2).T
Next
SkinLabel19.Caption = x
End Sub
neither it is not showing any thing on skinglabel19 nor showing any error
Try after pasting this code
-------------------------- ---------- ---------- ---------- ------
Private Sub DG_AfterColUpdate(ByVal ColIndex As Integer)
Dim x%, i%
x = 0
If ColIndex = 2 Then
For i = 0 To Dg.ApproxCount - 1
Dg.Row = i
x = x + Val(DataGrid1.Columns(2).T ext)
Next
SkinLabel19.Caption = x
End Sub
--------------------------
Private Sub DG_AfterColUpdate(ByVal ColIndex As Integer)
Dim x%, i%
x = 0
If ColIndex = 2 Then
For i = 0 To Dg.ApproxCount - 1
Dg.Row = i
x = x + Val(DataGrid1.Columns(2).T
Next
SkinLabel19.Caption = x
End Sub
ASKER
Sir no progress
A Slight Change is there in the above code.....
Sorry....
Please paste the below code and run....
-------------------------- ---------- ---------- -
Try after pasting this code
-------------------------- ---------- ---------- ---------- ------
Private Sub DG_AfterColUpdate(ByVal ColIndex As Integer)
Dim x%, i%
x = 0
If ColIndex = 2 Then
For i = 0 To Dg.ApproxCount - 1
Dg.Row = i
x = x + Val(Dg.Columns(2).Text)
Next
SkinLabel19.Caption = x
End Sub
-------------------------- ---------- ---------- ---------- --------
Good Luck
Sorry....
Please paste the below code and run....
--------------------------
Try after pasting this code
--------------------------
Private Sub DG_AfterColUpdate(ByVal ColIndex As Integer)
Dim x%, i%
x = 0
If ColIndex = 2 Then
For i = 0 To Dg.ApproxCount - 1
Dg.Row = i
x = x + Val(Dg.Columns(2).Text)
Next
SkinLabel19.Caption = x
End Sub
--------------------------
Good Luck
ASKER
Same no progress no error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sir Recrodset is running good I do not no why its not work on datagrid. However my problem resolve. Tks for assistance
Get the colindex for the particular amount column
--------------------------
Private Sub DataGrid1_AfterColUpdate(B
Dim x%,i%
x = 0
if colindex = <column index of amount field>
For i = 0 To DataGrid1.ApproxCount - 1
DataGrid1.Row = i
x = x + Val(DataGrid1.Columns(ColI
Next
Label1.Caption = x
End Sub