Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to sum all value in datagid column?

krazieYNEJkrazieYNEJ Member Posts: 3
hi! Can someone help me with my proposed study. I have a column in a datagrid to be sum up but I dunno knoe how to perform the sum operation in datagrid and average at the same time.. :))
--
I have a field column (Course Code,Unit,Grade,Remarks) I just use a query for the Unit.. I need to add the units having a grade of 5.00 or 4.00 then divide it with the total units of subject enrolled.. I've tried to use a query in access but when I connect it to vb6 the error is type mismatch :)) I dunno if my code is correct

My code is like this:

Private Sub cmdcompute_Click()
Dim sumtotal As String
Dim sumfail As String
Dim avg As Integer

sumfail = "SELECT Sum(Curriculum_entries.Unit)" & _
"FROM Student_pros INNER JOIN Curriculum_entries ON Curriculum_entries.Course_code=Student_pros.Course_code" & _
"WHERE Curriculum_entries.Unit='" & dtpros.Columns(5).Text & "' AND Grade >= 4.00"

sumtotal = "SELECT Sum(Curriculum_entries.Unit)" & _
"FROM Student_pros INNER JOIN Curriculum_entries ON Curriculum_entries.Course_code=Student_pros.Course_code" & _
"WHERE Curriculum_entries.Unit='" & dtpros.Columns(5).Text & "' AND Student_pros.Grade >= 4.00" & Me.dtpros.Columns(6).Text & "'"

avg = (sumfail / sumtotal) * 100

If avg <= 24 Then
txtstatus.Text = "Regular"
Exit Sub
ElseIf 25 >= avg <= 49 Then
txtstatus.Text = "Warning"
Exit Sub
ElseIf 50 >= avg <= 74 Then
txtstatus.Text = "Probation"
Exit Sub
ElseIf avg >= 75 Then
txtstatus.Text = "Dismissal"
End If

End Sub

Comments

Sign In or Register to comment.